From: tim
Here's what im trying to do and maybe you have a different way to
approach
it.
I have a datatable with a couple of columns, user & queue. I load the
table using the Get statement. I would like the user to be able to
click on either the user or queue fields (would become links I guess).
Once they make there clicking selection, a new webpage would be called
passing the value of what they clicked.
From: Joe Pluta
You want a clickable table. There's support in the base product for that.
Have you been through the tutorial information on Jon Sayles' site?
http://www.jsayles.com/ibm
I highly recommend this site.
Okay, I had a couple of minutes, so I looked into it. While JSF isn't
perfect, JSF makes most basic HTML requirements dirt-simple once you
understand the basic concepts. In this case, the concept is to add a link,
which is the outputLink tag, and attach a variable from the dataTable.
I assume you have a dataTable, and in it you have an outputText. Simply
surround the outputText with an outputLink and you're done:
<h:outputLink value="MyPage2.jsp">
<h:outputText id="textName" value="#{varrows.Name}"
binding="#{MyPage1.rows_Name_Ref}" styleClass="outputText">
</h:outputText>
<f:param name="id" id="param1" value="#{varrows.ID}"></f:param>
</h:outputLink>
There are three lines for the link: the h:outputLink and the /h:outputLink
are pretty obvious, but the f:param is the crucial bit; it attaches the
variable from the table to the URL. It takes a field named ID out of the
current row of varrows (which is the name of the variable holding the table
data). It will create a link that will look something like this:
"MyPage2.jsp?id=634".
It would be a bit easier if you included your JSF source, but hopefully this
will get you moving in the right direction. By the way, I think you can do
most of this using the WYSIWYG editor; it makes it real easy to add a link
and then add a parameter to the link.
In my case, I called the first page MyPage1, and the second page MyPage2.
MyPage2 is expecting a prarameter named "id". The dataTable variable is
named "rows", and has fields "Name" and "ID".
As you can see, it takes more time to explain it than to do it! Which is
usually a good sign that you've done it correctly. :)
Joe
As an Amazon Associate we earn from qualifying purchases.