File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes h:commandLink is not working within h:dataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:commandLink is not working within h:dataTable" Watch "h:commandLink is not working within h:dataTable" New topic
Author

h:commandLink is not working within h:dataTable

vinutha
Greenhorn

Joined: Nov 29, 2006
Posts: 29
Hi,

In my xhtml page, i am using h:dataTable like this,
After clicking Search button, i will get list of patients based on FirstName and LastName.
<h:inputText value="#{pmsPatientWebGuiListBean.firstName}" />
<h:inputText value="#{pmsPatientWebGuiListBean.lastName}" />
<h:commandButton value="Search"
action="#{pmsPatientWebGuiListBean.searchPatient}"/>
<h:dataTable id="adresstable"
value="#{pmsPatientWebGuiListBean.pmsPatients}"
var="patient">
<h:column id="firstname">
<f:facet name="header">
<hutputText value="First Name" />
</f:facet>
<h:commandLink action="#{pmsPatientWebGuiListBean.select}" >
<hutputText value="#{patient.firstName}" />
</h:commandLink>
</h:column>
</h:dataTable>

but when i click command link of first name, its not goint to #{pmsPatientWebGuiListBean.select} action.

How to resolve this,
Thanks,
Vinutha.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Did you put your code within the

<h:form>
</h:form>

tags.

I experience sometimes that the <h:commandbutton> is not working when it's not within a form.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Sorry I see it's the <h:commandLink />

This is also certain true with the <h:commandLink> button because it's submits the enclosing form.
vinutha
Greenhorn

Joined: Nov 29, 2006
Posts: 29
Hi wilhelm,

Thanks for your reply.
I have included <h:commandLink /> within <h:form></h:form>.
even though its not identifying action method under bean class.

Thanks,
Vinutha.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Did you check the following link.

Maybe you can find the solution in here

Sun Developer Network "dataTable and commandLink not working together"

I've tried the combination within dataTable and commandLink and it worked.
vinutha
Greenhorn

Joined: Nov 29, 2006
Posts: 29
Hi wilhelm,

Thanks for your response,
I solved that problem by keeping managed bean under session.

Thanks,
Vinutha.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

"vinutah ml", you have previously been warned on one or more occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Be aware that accounts with invalid display names are removed.

bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

"vinutha"

Your name is still not correct. Please review the naming policy and update it. This is your third and final warning.


My Blog: Down Home Country Coding with Scott Selikoff
Brian Moran
Greenhorn

Joined: Dec 24, 2009
Posts: 7
vinutha wrote:Hi,

In my xhtml page, i am using h:dataTable like this,
After clicking Search button, i will get list of patients based on FirstName and LastName.
<h:inputText value="#{pmsPatientWebGuiListBean.firstName}" />
<h:inputText value="#{pmsPatientWebGuiListBean.lastName}" />
<h:commandButton value="Search"
action="#{pmsPatientWebGuiListBean.searchPatient}"/>
<h:dataTable id="adresstable"
value="#{pmsPatientWebGuiListBean.pmsPatients}"
var="patient">
<h:column id="firstname">
<f:facet name="header">
<hutputText value="First Name" />
</f:facet>
<h:commandLink action="#{pmsPatientWebGuiListBean.select}" >
<hutputText value="#{patient.firstName}" />
</h:commandLink>
</h:column>
</h:dataTable>

but when i click command link of first name, its not goint to #{pmsPatientWebGuiListBean.select} action.

How to resolve this,
Thanks,
Vinutha.


The only way I've been able to get commandlinks to work inside of a datatable is to set the scope of the backing bean to session in faces-config. Try that out and see if it works for you.


SCJA
Frank S Liu
Greenhorn

Joined: Jan 10, 2011
Posts: 1
It is still not working for me.

I put the h:commandLink inside h:form tags, and my backing bean is session scoped, but it is not responding.

Can someone please advise?

Thank you
Frank
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: h:commandLink is not working within h:dataTable