• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

DataTable with CommandLinks

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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">
<hx:outputLinkEx
styleClass="outputLinkEx"
id="linkEx1"
onklick="return func_1(#{varagents.id});"
value="#">
<h:outputText id="text2" styleClass="outputText"
value="#{varagents.id}"></h:outputText>
</hx:outputLinkEx>
</h:column>
</h:dataTable>

<h:outputText styleClass="outputText" id="text1" value="#{param.slectedAgentID}"></h:outputText>
</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 ]
 
I love a good mentalist. And so does this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic