Meaningless Drivel is fun!*
The moose likes JSF and the fly likes DataTable with CommandLinks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "DataTable with CommandLinks" Watch "DataTable with CommandLinks" New topic
Author

DataTable with CommandLinks

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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

Joined: Jul 11, 2001
Posts: 15299
    
    6

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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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">
<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 ]

If the compiler ain't happy then no body is....<br /> <br />SCJP 1.4
 
jQuery in Action, 2nd edition
 
subject: DataTable with CommandLinks
 
Similar Threads
Bean request Scope won't Call method
Using of nested Datatables
Array of Object in DataTable
Simple list table
dataTable troubles