Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DataTable with CommandLinks

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your backing bean in request scope? If yes, try putting it into session scope and see if the method is being called then.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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">
<hxutputLinkEx
styleClass="outputLinkEx"
id="linkEx1"
onklick="return func_1(#{varagents.id});"
value="#">
<hutputText id="text2" styleClass="outputText"
value="#{varagents.id}"></hutputText>
</hxutputLinkEx>
</h:column>
</h:dataTable>

<hutputText styleClass="outputText" id="text1" value="#{param.slectedAgentID}"></hutputText>
</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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic