DataTable as Composite Component with LazyDataModel Not Working - jsf

I am facing problems while trying to use primefaces datatable as composite component.
Below are my code snippet:
commonDataTable.xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui">
<composite:interface>
<composite:attribute name="rows" />
<composite:attribute name="value" type="org.primefaces.model.LazyDataModel"/>
<composite:attribute name="var" />
<composite:attribute name="id" />
<composite:attribute name="rowStyle" />
</composite:interface>
<composite:implementation>
<p:dataTable value="#{composite.attrs.value}"
rendered="#{not empty composite.attrs.value}"
id="composite.attrs.id" var="composite.attrs.var" paginator="true" rows="25"
currentPageReportTemplate="Showing {startRecord}-{endRecord} of {totalRecords}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="25,50,100" paginatorPosition="bottom"
lazy="true" rowStyleClass="#{composite.attrs.rowStyle}">
<composite:set target="#{component}" property="var" value="#{composite.attrs.var}"/>
<composite:insertChildren />
</p:dataTable>
</composite:implementation>
</ui:composition>
index.xhtml:
<ui:composition template="/WEB-INF/template/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:t="http://java.sun.com/jsf/composite/components">
<ui:param name="pageTitle" value="My Page" />
<f:metadata>
<f:viewParam id="employeeId" name="employeeId" value="#{mySummaryBean.employeeId}" required="false" />
<f:viewParam id="employee" name="employee" value="#{mySummaryBean.employee}" required="false" />
<f:event type="preRenderView" listener="#{mySummaryBean.preRender}" />
</f:metadata>
<ui:define name="content">
<p:fieldset>
<h2>employee Overview</h2>
<h:form>
<p:messages id="messages" showDetail="true" autoUpdate="true"
closable="true" />
<p:panel rendered="#{not empty mySummaryBean.employeeRunModel}">
<t:commonDataTable var="run" value="#{mySummaryBean.employeeRunModel}" rows="10"
id="carTable"
rowStyle="#{run.runErrorStatus}">
.........
</t:commonDataTable>
</p:panel>
</h:form>
</p:fieldset>
</ui:define>
</ui:composition>
Does anyone got datatable working inside a composite component with LazyDataModel?

After playing with Primeface, I am now able to resolve the issue. Sharing the solution so that it can help others if required.
commonDataTable.xhtml:
<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<cc:interface>
<cc:attribute name="rows" />
<cc:attribute name="value"
type="org.primefaces.model.LazyDataModel" />
<cc:attribute name="var" />
<cc:attribute name="id" />
<cc:attribute name="rowStyle" />
</cc:interface>
<cc:implementation>
<p:dataTable value="#{cc.attrs.value}"
rendered="#{not empty cc.attrs.value}" id="#{cc.attrs.id}"
paginator="true" rows="25"
currentPageReportTemplate="Showing {startRecord}-{endRecord} of {totalRecords}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="25,50,100" paginatorPosition="bottom"
lazy="true" rowStyleClass="#{cc.attrs.rowStyle}">
<c:set target="#{component}" property="var" value="#{cc.attrs.var}"/>
<cc:insertChildren />
</p:dataTable>
</cc:implementation>
</ui:component>
index.xhtml:
<ui:composition template="/WEB-INF/template/layout.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:t="http://java.sun.com/jsf/composite/components">
<ui:param name="pageTitle" value="My Page" />
<ui:define name="content">
<p:fieldset>
<h2>employee Overview</h2>
<h:form>
<p:messages id="messages" showDetail="true" autoUpdate="true"
closable="true" />
<p:panel rendered="#{not empty mySummaryBean.employeeRunModel}">
<t:commonDataTable var="employee" value="#{mySummaryBean.employeeRunModel}" rows="10"
id="employeeTable"
rowStyle="#{employee.employeeErrorStatus}">
.........
</t:commonDataTable>
</p:panel>
</h:form>
</p:fieldset>
</ui:define>
</ui:composition>

Related

Page redirect issue in Primefaces Tab?

Here is the code which i am trying to run
ChildTemplate.xhtml
<ui:composition template="../templates/home-template-new.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<h:outputStylesheet library="css" name="primeface_default.css" />
<p:tabView dynamic="true" cache="true" id="tabView">
<p:tab title="A">
<ui:insert name="equipList">
<ui:include src="../AList.xhtml" />
</ui:insert>
</p:tab>
<p:tab title="B">
<ui:insert name="terminationList">
<ui:include src="../BList.xhtml" />
</ui:insert>
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
Here is the BList.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui">
<p:dataTable value="#{bean.fetchTemp()}" var="temp" reflow="true" resizableColumns="true" liveResize="true"
id="table2">
<p:column>
........
........
</p:column>
<f:facet name="footer">
<div class="divTableFooter" align="right" id="footerDiv6">
<p:panelGrid>
<p:commandLink id="create"
action="#{bean.methodName()}">
</p:commandLink>
<h:link value="LinkName" outcome="AddRecord" />
</p:panelGrid>
</div>
</f:facet>
</p:dataTable>
</ui:composition>
Now let me define the problem
Right now my active tab is B and when i am clicking the <p:commandLink/> or <h:link /> It is redirecting and showing tab A while it should show AddRecord.xhtml page in current active tab B.
What is wrong with my code ? Can someone suggest it?
You can add activeIndex attribute to your tabview component and write a tabchange event using p:ajax .Please check the below code
<h:outputStylesheet library="css" name="primeface_default.css" />
<p:tabView dynamic="true" cache="true" id="tabView" activeIndex="#{bean.tabIndex}">
<p:ajax event="tabChange" listener="#{bean.onTabChange}" />
<p:tab title="Equipment" >
<ui:insert name="equipList">
<ui:include src="../AList.xhtml" />
</ui:insert>
</p:tab>
<p:tab title="Termination">
<ui:insert name="terminationList">
<ui:include src="../BList.xhtml" />
</ui:insert>
</p:tab>
</p:tabView>
in your bean define tabIndex variable and implement the onTabChange method
private boolean popupEdit;
public final void onTabChange(final TabChangeEvent event) {
TabView tv = (TabView) event.getComponent();
this.tabIndex = tv.getChildren().indexOf(event.getTab());
}
Hope this will help you

JSF mojarra with primefaces migration from Glassfish to Wildfly - CSS and theme not loading

We are migrating our App from glassfish to wildfly. However, the primefaces theme no longer loads. I am attaching the pages which are loaded .
Firebug console shows an error - ReferenceError: $ is not defined
Index.xhtml
`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<h:head>
<link rel="shortcut icon"
href="http://www.hs-furtwangen.de/fileadmin/templates/favicon.ico"
type="image/x-ico; charset=binary" />
<f:facet name="first">
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type" />
<title>#{messages.finquasCompleteName}</title>
</f:facet>
</h:head>
<h:body>
<ui:composition template="./mainTemplate.xhtml">
<ui:define name="NonServiceView">
<h:form>
<p:growl autoUpdate="true" />
<div class="activitySream">
<div class="activityStreamHeader">
#{messages.activityStream}
</div>
<p:outputPanel deferred="true">
<p:dataList id="id_list_activity_stream"
value="#{activityStreamController.logEntries}" var="logEntry"
type="none" emptyMessage="#{messages.noActivitiesFound}">
<div class="activityDescriptionArea">
<div class="activityIconArea">
<h:outputText value="#{activityStreamController.getActionSpecificIconCode(logEntry.changeType)}"
escape="false" />
</div>
<div class="activityDescription">
<h:outputText value="#{logEntry.creator.name}" styleClass="boldLabel" />
<h:outputText value="#{activityStreamController.getActivityTextFirstPartForLogEntry(logEntry)}" />
<h:commandLink styleClass="boldLabel"
action="#{activityStreamController.navigateToEntity(logEntry.abstractEntity)}">
#{activityStreamController.getEnitityText(logEntry.abstractEntity)}
</h:commandLink>
<h:outputText value="#{activityStreamController.getChangeLogLabelOfLogEntry(logEntry)}." />
<div class="activityDate">
<h:outputText value="#{logEntry.changeDate}">
<f:convertDateTime pattern="dd.MM.yyyy HH:mm:ss" timeZone="Europe/Berlin" />
</h:outputText>
</div>
</div>
</div>
</p:dataList>
<p:commandButton value="#{messages.showMore}" action="#{activityStreamController.showMore()}"
update="id_list_activity_stream"
rendered="#{not empty activityStreamController.logEntries}"
styleClass="plainText greenButton showMoreActivitiesButton"/>
</p:outputPanel>
</div>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>`
mainTemplate.xhtml
`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<h:body>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:composition template="./headerFooterLoggedInPagesTemplate.xhtml">
<ui:define name="leftHeaderUnit">
<p:commandButton
id="id_btn_home"
action="#{navigationController.navigateHome()}"
value="#{iconSetController.home}"
escape="false" title="#{messages.home}"
update=":structureTreeForm" ajax="false" />
</ui:define>
<ui:define name="rightHeaderUnit">
<p:commandButton id="id_btn_main_user_profile"
action="userProfile"
title="#{messages.myProfile}"
value="#{iconSetController.user}"
ajax="false"
escape="false" />
<p:commandButton id="id_btn_main_help"
action="help"
title="#{messages.help}"
value="#{iconSetController.help}"
escape="false" />
<p:commandButton id="id_btn_main_logout"
title="#{messages.logout}"
value="#{iconSetController.logout}"
escape="false"
action="#{navigationController.logout()}" />
</ui:define>
<!--The empty header field is a necessary in order to display the collapsible button-->
<ui:define name="navigationArea">
<p:layoutUnit position="west"
collapsible="true"
header=""
effect="none"
resizable="true" id="id_lu_navigationBarLeft" size="320" minSize="300">
<p:tabView id="id_tabView_navigationBar"
dynamic="true"
activeIndex="#{navigationController.activeNavigationBarTabIndex}"
styleClass="finquasTabs">
<p:ajax event="tabChange" listener="#{navigationController.onNavigationBarTabChange}" />
<p:tab title="#{messages.myServicesTab}">
<p:panel rendered="#{not empty navigationController.administrationServicesOfCurrentUser}" header="#{messages.myAdministrationServices}">
<h:form id="myAdministrationServicesForm">
<p:dataList id="id_list_my_administration_services"
value="#{navigationController.administrationServicesOfCurrentUser}"
var="service"
rendered="#{not empty navigationController.administrationServicesOfCurrentUser}">
<p:column>
<h:commandLink
action="#{navigationController.viewServiceViaObject(service)}">
#{service.name}
</h:commandLink>
</p:column>
</p:dataList>
</h:form>
</p:panel>
<p:panel rendered="#{not empty navigationController.educationalServicesOfCurrentUser}" header="#{messages.myEducationalServices}">
<h:form id="myEducationalServicesForm">
<p:dataList id="id_list_my_product_services"
value="#{navigationController.educationalServicesOfCurrentUser}"
var="service"
rendered="#{not empty navigationController.educationalServicesOfCurrentUser}">
<p:column>
<h:commandLink
action="#{navigationController.viewServiceViaObject(service)}">
<h:outputText value="#{service.name}" />
<h:outputText value=" #{messages[service.getDegree().getAbbreviation()]}#{messages[service.getDegreeType().getAbbreviation()]}" rendered="#{navigationController.isDegreeProgram(service)}"/>
<h:outputText value=" #{navigationController.getStateOfService(service)}" rendered="#{navigationController.isServiceDegreeProgramOrStudyModule(service)}"/>
</h:commandLink>
</p:column>
</p:dataList>
</h:form>
</p:panel>
<p:panel rendered="#{not empty navigationController.peerReviewsOfCurrentUser}" header="#{messages.myPeerReviews}">
<h:form id="myPeerReviewsForm">
<p:dataList id="id_list_my_review_services"
value="#{navigationController.peerReviewsOfCurrentUser}"
var="service"
rendered="#{not empty navigationController.peerReviewsOfCurrentUser}">
<p:column>
<h:commandLink
action="#{navigationController.viewServiceViaObject(service)}">
#{service.name} (#{messages[service.state.class.name]})
</h:commandLink>
</p:column>
</p:dataList>
</h:form>
</p:panel>
<p:panel rendered="#{not empty navigationController.qualityReportServicesOfCurrentUser}" header="#{messages.myQualityReportServices}">
<h:form id="myQualityReportServicesForm">
<p:tree id="id_list_my_quality_report_services"
value="#{navigationController.qualityReportServiceRoot}"
var="serviceNode"
dynamic="true"
rendered="#{not empty navigationController.qualityReportServicesOfCurrentUser}">
<p:ajax event="expand" listener="#{navigationController.onNodeExpandQualityReportGraph}" />
<p:ajax event="collapse" listener="#{navigationController.onNodeCollapse}" />
<p:treeNode>
<h:commandLink
action="#{navigationController.viewServiceViaObject(serviceNode)}">
<span title="#{messages.qualityReportFinished}"><h:panelGroup layout="block" class="greenCircle" rendered="#{serviceNode.state.position == 3}"/> </span>
<span title="#{messages.qualityReportWaitingForStatement}"><h:panelGroup layout="block" class="yellowCircle" rendered="#{serviceNode.state.position == 2}"/></span>
<span title="#{messages.qualityReportWaitingForStatementStudyDean}"><h:panelGroup layout="block" class="redCircle" rendered="#{serviceNode.state.position == 1}"/></span>
#{serviceNode.simpleName}
</h:commandLink>
</p:treeNode>
</p:tree>
</h:form>
</p:panel>
</p:tab>
<p:tab title="#{messages.serviceStructureTab}">
<p:panel header="#{messages.search}" styleClass="finquasinput">
<h:form id="id_form_main_search">
<p:autoComplete id="id_input_main_search"
forceSelection="true"
placeholder="#{messages.autoCompleteHint}"
value="#{navigationController.serviceName}"
effect="fade"
required="true"
requiredMessage="#{messages.noServiceFound}"
styleClass="autocompleteService"
completeMethod="#{navigationController.completeService}" />
<p:commandButton id="id_btn_main_search"
value="#{iconSetController.search}" escape="false"
action="#{navigationController.viewServiceViaAutoComplete}"
ajax="false" />
</h:form>
</p:panel>
<p:panel header="#{messages.structure}">
<h:form id="structureTreeForm">
<p:tree value="#{navigationController.serviceRoot}"
dynamic="true"
var="serviceNode"
styleClass="finquastree"
animate="true">
<p:ajax event="expand" listener="#{navigationController.onNodeExpandEducationalServiceGraph}" />
<p:ajax event="collapse" listener="#{navigationController.onNodeCollapse}" />
<p:treeNode>
<h:commandLink
action="#{navigationController.viewServiceViaObject(serviceNode)}">
<h:outputText value="#{serviceNode.name} #{messages[serviceNode.getDegree().getAbbreviation()]}#{messages[serviceNode.getDegreeType().getAbbreviation()]}" rendered="#{serviceNode['class'].simpleName == 'DegreeProgram'}"/>
<h:outputText value="#{serviceNode.name}" rendered="#{serviceNode['class'].simpleName != 'DegreeProgram'}"/>
</h:commandLink>
</p:treeNode>
</p:tree>
</h:form>
</p:panel>
</p:tab>
</p:tabView>
</p:layoutUnit>
</ui:define>
</ui:composition>
</ui:composition>
</h:body>
</html>`
headerFooterTemplate.xhtml
`
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<h:body>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<ui:insert name="loggedInCheck" />
<f:facet name="last">
<h:outputStylesheet library="css" name="default.css" />
<h:outputScript library="scripts" name="primefacesLocalization.js"
target="head" />
</f:facet>
<p:layout fullPage="true">
<p:layoutUnit id="id_lu_headerUnit" position="north">
<h:form id="id_form_headerForm">
<p:toolbar styleClass="finquasheader">
<p:toolbarGroup styleClass="headerBar">
<ui:insert name="leftHeaderUnit" />
</p:toolbarGroup>
<p:toolbarGroup align="right" styleClass="headerBar">
<ui:insert name="rightHeaderUnit" />
</p:toolbarGroup>
</p:toolbar>
</h:form>
</p:layoutUnit>
<ui:insert name="navigationArea" />
<p:layoutUnit id="id_lu_centerUnit" position="center">
<div id="contentArea">
<div class="nonServiceView">
<ui:insert name="NonServiceView" />
</div>
<ui:insert name="ServiceView" />
</div>
</p:layoutUnit>
<p:layoutUnit position="south" id="footerUnit">
<h:form>
<p:toolbar styleClass="finquasfooter">
<p:toolbarGroup>
<ui:insert name="leftFooterContent" />
</p:toolbarGroup>
<p:toolbarGroup align="right" styleClass="footerToolbar">
#{messages.finquasCompleteName}
</p:toolbarGroup>
</p:toolbar>
</h:form>
</p:layoutUnit>
</p:layout>
</f:view>
</ui:composition>
</h:body>
</html>`
headerFooterLoggedInPagesTemplate.xhtml
` <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
>
<h:body>
<ui:composition template="./headerFooterTemplate.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
<ui:param name="currentUser" value="#{sessionController.currentUser}" />
<ui:define name="loggedInCheck">
<c:if test="#{!sessionController.loggedIn}">
<meta HTTP-EQUIV="REFRESH"
content="0;URL='#{navigationController.serverUrl}'" />
</c:if>
</ui:define>
<ui:define name="leftFooterContent">
#{currentUser.firstName} #{currentUser.lastName}
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-49887094-1', 'hs-furtwangen.de');
ga('send', 'pageview');
</script>
</ui:define>
</ui:composition>
</h:body>
</html>`
I got the error. All my template pages were using composition and each had its own head tag. While this worked with glassfish, wildfly did not allow it.
Removing head from all but the base template and making the base template not a composition solved this

Problems using Composite JSF with DataTable

Well, i'm starting to use Composite JSF 2.0 and i have a following problem.
This is my composite:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
</composite:interface>
<composite:implementation>
<p:ajax event="rowSelect" update="#form" />
<p:ajax event="rowUnselect" update="#form" />
</composite:implementation>
</html>
And i'm trying to use this composite in this way:
<p:dataTable rowKey="#{cartao.id}" var="cartao"
value="#{cartaoCreditoMB.beans}" paginator="true"
emptyMessage="Não foi encontrado nenhum registro" rows="10"
id="dataTableCartoesCredito" selection="#{cartaoCreditoMB.bean}"
selectionMode="single">
<application:rowSelectUnSelect />
</p:dataTable>
But i got the following error:
/resources/application/rowSelectUnSelect.xhtml #14,45 <p:ajax> Unable to attach <p:ajax> to non-ClientBehaviorHolder parent
These two lines :
<p:ajax event="rowSelect" update="#form" />
<p:ajax event="rowUnselect" update="#form" />
have to be nested in a component that implements the ClientBehaviourHolder interface.
Possibly, you need to nest those <p:ajax> inside the <p:dataTable> instead:
<p:dataTable ...>
<p:ajax ... />
...
</p:dataTable>
since the DataTable class does implement the ClientBehaviourInterface.

selectManyMenu selection values inside a composite

I've created a composite that contains the PrimeFaces selectManyMenu. I'm attempting to pass the bound selection value into the composite, but it fails.
Composite code:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<composite:interface>
<composite:attribute name="selectedUsers" required="true"/>
<composite:attribute name="users" required="true" type="java.util.List"/>
<composite:attribute name="recommendActionHandler" required="true" method-signature="void listener()"/>
<composite:attribute name="recommendButtonStyle"/>
<composite:clientBehavior name="click" event="change" targets="recommendUsers" default="true"/>
</composite:interface>
<composite:implementation>
<div id="#{cc.clientId}">
<h:form id="recommendForm" prependId="false">
<p:growl id="recommendGrowl" showDetail="true"/>
<p:commandButton id="recommendBtn" value="Recommend" type="button" update=":recommendForm,recommendUsers" style="#{cc.attrs.recommendButtonStyle}"/>
<p:overlayPanel id="recommendPanel" for="recommendBtn" widgetVar="recommendPanel"
dynamic="true"
hideEffect="fade"
showCloseIcon="true">
<p:selectManyMenu id="recommendUsers" value="#{cc.attrs.selectedUsers}" showCheckbox="true"
style="width:150px;height:200px">
<f:selectItems value="#{cc.attrs.users}" var="user" itemLabel="#{user.login}" itemValue="#{user.login}"/>
</p:selectManyMenu>
<p:commandButton id="submitRecommendations"
value="Send"
update="recommendUsers recommendGrowl"
actionListener="#{cc.attrs.recommendActionHandler}"
process="recommendUsers #this"
/>
</p:overlayPanel>
</h:form>
</div>
</composite:implementation>
</html>
View code:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
>
<ui:composition template="/WEB-INF/facelet_templates/default.xhtml">
<ui:define name="content">
<kf:recommend id="recommendIt"
selectedUsers="#{recommendViewBean.selectedUsers}"
users="#{recommendViewBean.users}"
recommendActionHandler="#{recommendController.saveRecommendations()}"
/>
</ui:define>
</ui:composition>
</html>
View bean code:
public class RecommendViewBean {
private List<UserType> users = new ArrayList<UserType>();
private List<String> selectedUsers = new ArrayList<String>();
//setters and getters...
}
In the code above, the value selectedUsers is the value in question. I pass the view/backing bean's List value that holds the selections for the selectManyMenu's value attribute. This works great when outside of a composite or if I pass the view bean like this...
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
>
<ui:composition template="/WEB-INF/facelet_templates/default.xhtml">
<ui:define name="content">
<kf:recommend id="recommendIt"
selectedUsers="#{recommendViewBean}"
users="#{recommendViewBean.users}"
recommendActionHandler="#{recommendController.saveRecommendations()}"
/>
</ui:define>
</ui:composition>
</html>
...
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:kf="http://java.sun.com/jsf/composite/kf"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<composite:interface>
<composite:attribute name="selectedUsers" required="true"/>
<composite:attribute name="users" required="true" type="java.util.List"/>
<composite:attribute name="recommendActionHandler" required="true" method-signature="void listener()"/>
<composite:attribute name="recommendButtonStyle"/>
<composite:clientBehavior name="click" event="change" targets="recommendUsers" default="true"/>
</composite:interface>
<composite:implementation>
<div id="#{cc.clientId}">
<h:form id="recommendForm" prependId="false">
<p:growl id="recommendGrowl" showDetail="true"/>
<p:commandButton id="recommendBtn" value="Recommend" type="button" update=":recommendForm,recommendUsers" style="#{cc.attrs.recommendButtonStyle}"/>
<p:overlayPanel id="recommendPanel" for="recommendBtn" widgetVar="recommendPanel"
dynamic="true"
hideEffect="fade"
showCloseIcon="true">
<p:selectManyMenu id="recommendUsers" value="#{cc.attrs.selectedUsers.selectedUsers}" showCheckbox="true"
style="width:150px;height:200px">
<f:selectItems value="#{cc.attrs.users}" var="user" itemLabel="#{user.login}" itemValue="#{user.login}"/>
</p:selectManyMenu>
<p:commandButton id="submitRecommendations"
value="Send"
update="recommendUsers recommendGrowl"
actionListener="#{cc.attrs.recommendActionHandler}"
process="recommendUsers #this"
/>
</p:overlayPanel>
</h:form>
</div>
</composite:implementation>
</html>
So, my question is, how would I pass the appropriate bound value for selectManyMenu's value attribute into the composite?
Thanks so much. Let me know if I need to explain more.

Primefaces datalist ajax-pagination dialog not updated

I'm trying to use primefaces dialog update method by primefaces here and i've replaced the bean and its methods with my bean.
This is what i did
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../Styles/homepage-style.css" />
<link rel="stylesheet" type="text/css" href="../Styles/profile.css" />
<title>Shadi Bandhan | We find the best match for you</title>
</h:head>
<h:body>
<h:form id="form">
<p:dataList value="#{messagesManagedBean.userInboxMsgs}" var="msg" id="cars"
paginator="true" rows="5"
paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" type="none">
<f:facet name="header">
Cars
</f:facet>
<p:commandButton icon="ui-icon-search" update=":form:carDetail" oncomplete="carDialog.show()" title="View Detail">
<f:setPropertyActionListener value="#{msg}" target="#{messagesManagedBean.selectedMessage}" />
</p:commandButton>
<h:outputText value="#{msg.message}, #{msg.userFullname}" style="margin-left:10px" />
<br />
</p:dataList>
<p:dialog header="Car Detail" widgetVar="carDialog" modal="true" showEffect="fade">
<p:outputPanel id="carDetail" style="text-align:center;" layout="block">
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="modelNo" value="Message: " />
<h:outputText id="modelNo" value="#{messagesManagedBean.selectedMessage.message}" />
<h:outputLabel for="year" value="Full name: " />
<h:outputText id="year" value="#{messagesManagedBean.selectedMessage.userFullname}" />
<h:outputLabel for="color" value="User Id: " />
<h:outputText id="color" value="#{messagesManagedBean.selectedMessage.userId}" style="color:#{tableBean.selectedCar.color}"/>
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</h:body>
</html>
It opens the dialog but does not show the values. (Dialog is not getting updated)
*Note*Before, when i used ui:repeat instead of datalist, it was fine with the f:param method.
Thanks
<h:form id="form">
<p:dataList value="#{tableBean.cars}" var="car" id="cars"
paginator="true" rows="10"
paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,15" type="none">
<p:column>
<f:facet name="header">
Notificaciones
</f:facet>
<p:commandButton icon="ui-icon-search" update=":form:carDetail" oncomplete="carDialog.show()" title="View Detail">
<f:setPropertyActionListener value="#{car}" target="#{tableBean.selectedCar}" />
</p:commandButton>
<h:outputText value="#{car.manufacturer}, #{car.year}" style="margin-left:10px" />
<br />
</p:column>
</p:dataList>
And the answer is
Putting the commandlink or commandbutton in the <p:column></p:column> solved my problem.

Resources