Command Link not invoking Backend Bean

Components, Ajax Framework, Utilities and More.
Post Reply
abdulrahmanar
Posts: 11
Joined: 31 Oct 2016, 05:22

10 Jul 2017, 09:47

Hi,

Based on this topic i have searched a lot, after trying all the suggestions i couldn't find solution to my problem. So only i am posting this.

I have a datatable -> column -> commandlink.

When i click the commandlink, the backend bean has to invoke and update the values of the bean and same to be update in the datatable.

Whenever i am clicking the commandlink on the first page(pagination), the call is invoking. If i click on other pages(other than 1st page), it doesn't invoke the backend bean rather it redirects to the 1st page of the datatable.

I have tried many solutions like ajax=false or true, process="@this", action or actionListener, kept bean in ViewScope or SessionScope.

Environment:
IBM WebSphere Portal 8.5

Following is the code, please help to suggest the solution.

Code: Select all

<!-- jsf:pagecode language="java" location="/src/pagecode/CommandLinkTestView.java" --><!--/jsf:pagecode -->
<div xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:portlet="http://java.sun.com/portlet_2_0"
	xmlns:p="http://primefaces.org/ui">

<h:head>
</h:head>

<h:body>
<h:form>
<div class="ui-fluid">
<div class="ui-g">
<div class="ui-g-12 ui-lg-12 ui-md-12".
<h4>Data Table</h4>
<p:dataTable id="consultanttable" var="consultant" value="#{commandLinkTestBean.consultants}" widgetVar="filteredConsultant" paginator="true" rows="5" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,10,15" reflow="true" styleClass="porDataTable">

	<f:facet name="header">
		List of Consultants
	</f:facet>
	
	<p:column headerText="Id" style="text-align: center;">
		<h:outputText value="#{consultant.id}"></h:outputText>
	</p:column>
	
	<p:column headerText="Type" style="text-align: center;">
		<h:outputText value="#{consultant.assessmentType}"></h:outputText>
	</p:column>
	
	<p:column headerText="Stage" style="text-align: center;">
		<h:outputText value="#{consultant.stage}"></h:outputText>
	</p:column>
	
	<p:column headerText="Temp Title" style="text-align: center;">
		<h:outputText value="#{consultant.tempTitle}"></h:outputText>
	</p:column>
	
	<p:column headerText="Updated By" style="text-align: center;">
		<h:outputText value="#{consultant.updatedBy}"></h:outputText>
	</p:column>
	
	<p:column headerText="Updated On" style="text-align: center;">
		<h:outputText value="#{consultant.dateUpdated}">
			<f:convertDateTime pattern="dd/MM/yyyy"></f:convertDateTime>
		</h:outputText>
	</p:column>
	
	<p:column headerText="Status" style="text-align: center;">
		<p:commandLink action="#{commandLinkTestBean.commandLinkCheck}" value="Status">
		</p:commandLink>
	</p:column>
	
<p:dataTable>
</div>
</div>
</div>
</h:form>
</h:body>
</div>

abdulrahmanar
Posts: 11
Joined: 31 Oct 2016, 05:22

17 Jul 2017, 09:10

Can anyone please let me know suggestions on this issue.

kukeltje
Expert Member
Posts: 8578
Joined: 17 Jun 2010, 13:34
Location: Netherlands

17 Jul 2017, 11:00

http://stackoverflow.com/questions/2118 ... nput-value

And an h:body and h:head inside a div???
Ronald van Kuijk
______________________________
PrimeFaces 5.2, PrimeFaces plus 0.0.2 | JbossWildfly 8.1| Mojarra 2.2.8
Fedora 21, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

abdulrahmanar
Posts: 11
Joined: 31 Oct 2016, 05:22

27 Jul 2017, 10:14

Hi,

I have tried all the solutions in the provided link, still it's not working.

Yes, h:body and h:head are inside the div.

pilpin
Posts: 9
Joined: 05 Jan 2017, 20:55

28 Jul 2017, 11:25

I think you should replace this :

Code: Select all

<div xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:portlet="http://java.sun.com/portlet_2_0"
	xmlns:p="http://primefaces.org/ui">
	...
</div>
with this :

Code: Select all

<html xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:portlet="http://java.sun.com/portlet_2_0"
	xmlns:p="http://primefaces.org/ui">
	...
</html>
You also have a typo here

Code: Select all

<div class="ui-g-12 ui-lg-12 ui-md-12".
which should be

Code: Select all

<div class="ui-g-12 ui-lg-12 ui-md-12">
PrimeFaces 6.1
Payara 172

abdulrahmanar
Posts: 11
Joined: 31 Oct 2016, 05:22

31 Jul 2017, 02:48

Hi,

I have tried with html, it's not working.

Typo is because of i have typed the entire code, i haven't done the copy and paste. So in my original code, it is closing tag not full stop.

kukeltje
Expert Member
Posts: 8578
Joined: 17 Jun 2010, 13:34
Location: Netherlands

31 Jul 2017, 09:47

Yes, h:body and h:head are inside the div.
That is wrong
Ronald van Kuijk
______________________________
PrimeFaces 5.2, PrimeFaces plus 0.0.2 | JbossWildfly 8.1| Mojarra 2.2.8
Fedora 21, Firefox 'most recent'
Read the forum posting rules
Beginners: https://jsf.zeef.com/bauke.scholtz

pilpin
Posts: 9
Joined: 05 Jan 2017, 20:55

31 Jul 2017, 10:23

Could you show us the code for the commandLinkCheck method ?
PrimeFaces 6.1
Payara 172

abdulrahmanar
Posts: 11
Joined: 31 Oct 2016, 05:22

16 Aug 2017, 08:56

Hi,

I have made it to work by following link suggestion.

https://stackoverflow.com/questions/316 ... -datatable

In case of dead link, here is the solution.

Use rows and first attributes in datatable, and bind it to the back end bean like below.

first="#{bean.first}" rows="#{bean.rows}".

Don't forget to create getter and setter for both fields.

Thongkon007
Posts: 1
Joined: 23 Jul 2017, 08:09

19 Aug 2017, 10:24

Thank you.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot] and 10 guests