| Author |
DataTable with CommandLinks
|
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
I am having a hard time with this. I have a dataTable which displays a detailed view of Issues. I want the Issue Number to be a link that takes to an even more detailed view of that specific Issue. But I am having a really hard time figuring out how to get the selected row when I click on the link. Right now I am doing this, paraphrased... In my backing bean I have the following: Now, when I click on the issue link the viewIssue method should be called. For some reason it is not. I click on the link in my page and the page is refreshed, but missing all the data. Not so concerned about the missing data right now as I am about the viewIssue method not even being called. Does anyone have any good reference/examples on how to do what I am trying to do. It seems like it should be easy, but appearntly they didn't make it that way unless I am overlooking something. Thanks.
|
 |
Varun Khanna
Ranch Hand
Joined: May 30, 2002
Posts: 1400
|
|
|
Is your backing bean in request scope? If yes, try putting it into session scope and see if the method is being called then.
|
- Varun
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Originally posted by Varun Khanna: Is your backing bean in request scope? If yes, try putting it into session scope and see if the method is being called then.
Well, my first attempt was I changed the h:dataTable to x:dataTable (using MyFaces) and it worked. I will try putting it in the session and seeing what happens with h:dataTable. Although I don't want it in the session.
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
Yes, putting it in the session seems to work. But I am not too keen on putting pages in the session that don't really need to be. Any other ideas? Is there a better way to do what I am trying to do?
|
 |
Varun Khanna
Ranch Hand
Joined: May 30, 2002
Posts: 1400
|
|
|
It's actually a bug, I have seen many heads banging over this issue in Sun JSF Forum. Only work around for this have been choosing a session scope instead of request scope.
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
I was under the impression it was fixed in JSF 1.1 though. Oh well. It's not detremental that this page be in the session. The only way to get to it is through another form, so it will always get updated info when it's called. Thanks for the tips.
|
 |
Marius Cloete
Greenhorn
Joined: Apr 14, 2005
Posts: 10
|
|
Hi this might not be the best way of doing it but here goes... <SCRIPT type="text/javascript"> function func_1(AgentId) { document.getElementById("form1:text1").value = AgentId; } </SCRIPT> <h:form styleClass="form" id="form1"> <!-- pc_Agent.agents returns a array of agents --> <h:dataTable id="table1" value="#{pc_Agent.agents}" var="varagents"border="0" style="background-color:#efebef;font-weight:bold"> <h:column id="column1"> <hx utputLinkEx styleClass="outputLinkEx" id="linkEx1" onklick="return func_1(#{varagents.id});" value="#"> <h utputText id="text2" styleClass="outputText" value="#{varagents.id}"></h utputText> </hx utputLinkEx> </h:column> </h:dataTable> <h utputText styleClass="outputText" id="text1" value="#{param.slectedAgentID}"></h utputText> </form> this way you send the id to the next page as a parameter. Hope this helped or give you new ideas  [ May 19, 2005: Message edited by: Marius Cloete ]
|
If the compiler ain't happy then no body is.... <br /> <br />SCJP 1.4
|
 |
 |
|
|
subject: DataTable with CommandLinks
|
|
|