• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

To view row specific data by clicking on the row link

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a DataTable with a hyper link on each row. If the user clicks on it, I would like to show the details of the selected row on another page "taken from database" in jsf please help me on that.

Thanks a lot in advance,
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

on another page


??? popup javascript
??? jsf/jsp page replace the datatable page
Please elaborate.
 
sameera srimal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


what i want to do is that by clicking on the

in the first.jsp file a datatable is consists of each one's private data (populated from database) and each row has a hyper link by clicking on that the it redirects to the personaldetail.jsp here that click person's private details are displayed.

i think that it is feasible to do using session but i can't understand how to use sent session id (by clicking hyper link) from first.jsp within personaldetail.jsp to display all of the personal data taken from database.


thanks for your help !
 
Samuel March
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What your asking is a little complicated if you are populating the page as a list from the database.
You need to know how to transfer that result-set information to a property reference each.
E.G. a cheap trick would be first getting a query such as mysql select count(distinct) where....
then collecting the same but the required identity information to send to each property of an array
governed by the previous distinct count.
The get method each time it is referred to by page call will trigger a bean internal method to ++ increment and retrieve each array value and a final special page call at the end of the page(another method) could reset the counter value to zero for next use.
usersNameOut would contain that ++ system, but your difficulty is matching page code(markup) output iterations.


first: declare your pages with the @ directive at the pagetop threadsafe="false"

second: with you JSF session bean, for the user (provided your not using JAAS)

<h:commandLink id="johnsmith"
action="detailspage"
actionListener="#{sessionBean.makePageChangeLtsn}">
<h:outputText value="#{sessionBean.usersNameOut}" />
</h:commandLink>

name of the beans [i]actionListener method in your session bean: makePageChangeLtsn[/i]
bean call inside faces-config.xml navigation rule
#{sessionBean.pageChangTo}




The actionlistener method you write must return( alike setWhereTo(String where) ) to the property(String where; // global) that holds the navigation value property configured in navigation by the rules in faces-config.xml

When the render phase(response) occurs the bean method that calls get on the where property must be set as the outcome in the navigation rule.

name of the method returning a List of usersDetails: usersDetails


You can take the hyperlinks out and replace with a commandbutton in a form that points to an outcome PAGE in your faces-config.xml navigation.

Either way it requires iteration over values from somewhere and storing individual forms for each set of details unique identifier information.

So you would see something like:
|| Jonh Smith || =buttonDETAILS= ||
|| Alison Jones || =buttonDETAILS= ||
....

inside the page this would look like where the button is (.faces or what your configured trigger is):

<form id="johnsmith" method="post" action="/applicationname/yourpage.faces">
<h:inputHidden name="SOMEPREFIX:name" id="SOMEPREFIX:name" value="Alison Jones" />
<h:commandButton id="SOMEPREFIX:submit" action="detailspage" value="Get Details" />
</form>

== table-row and table-data here == then

<form id="AlisonJones" method="post" action="/applicationname/yourpage.faces">
<h:inputHidden name="SOMEPREFIX:name" id="SOMEPREFIX:name" value="Alison Jones" />
<h:commandButton id="SOMEPREFIX:submit" action="detailspage" value="Get Details" />
</form>

in the detailspage use the value to query your database, you supply to that value what you need





 
Samuel March
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What the point is in JSF is, is that when you use it, it is a complete system. If you were to use AJAX or a servlet for processing a "form" it misses the point of using it.
You send the information from the first page "that will be some type of form" and process that information.

Contract for JSFusage:
So what you are saying you will do is to take an individuals unique details and send it to the JSF , if it turns out ok with a validator on the element or it makes sense automatically(as in a commandLink) you use the unique properties of that information inside the JSF Framework system to make a decision with.

So the next page will call on the the bean and is set with a unique value from the commandLink to call the database to query using that information.
In each commandLink or commandButton form you need to supply each piece of unique identifying information to use in the query as the second page gets processed.

You don't particularly need an JSF.ActionListener you can simply get the information from the click and always refer to the navigation-rule to bring that down after obtaining the unique identifying information.
 
You showed up just in time for the waffles! And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic