Meaningless Drivel is fun!*
The moose likes JSF and the fly likes To view row specific data by clicking on the row link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "To view row specific data by clicking on the row link" Watch "To view row specific data by clicking on the row link" New topic
Author

To view row specific data by clicking on the row link

sameera srimal
Greenhorn

Joined: Nov 05, 2009
Posts: 7

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,
Samuel March
Ranch Hand

Joined: Oct 28, 2009
Posts: 39
on another page

??? popup javascript
??? jsf/jsp page replace the datatable page
Please elaborate.


...did you have the fish?!............................ No.
sameera srimal
Greenhorn

Joined: Nov 05, 2009
Posts: 7


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

Joined: Oct 28, 2009
Posts: 39
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}">
<hutputText 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

Joined: Oct 28, 2009
Posts: 39
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.
 
wood burning stoves
 
subject: To view row specific data by clicking on the row link