Anyone know how to pass the selected row values.I need to update the data table when the when the Approve button is pressed.
mainpage.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 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"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="notes">
<h:form>
<p:commandButton value="Sick Leave" action="sickleave" id="sickleave"/>
<p:commandButton value="Paid off Leave" action="paidleave" id="paidleave"/>
</h:form>
</ui:define>
<ui:define name="content">
<h2>Approve Leave</h2>
<h:form>
<h:dataTable value="#{employeeleave}" var="e"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row"
columnClasses="order-table-odd-column,order-table-even-column"
>
<h:column>
<f:facet name="header">
No.
</f:facet>
#{e.employeeId}
</h:column>
<h:column>
<f:facet name="header">
Start Date
</f:facet>
#{e.startDate}
</h:column>
<h:column>
<f:facet name="header">
End Date
</f:facet>
#{e.endDate}
</h:column>
<h:column>
<f:facet name="header">
Reason
</f:facet>
#{e.reason}
</h:column>
<h:column>
<f:facet name="header">
Status
</f:facet>
<h:selectOneMenu id="approveleavetype" value="#{employeeLeave.status}">
<f:selectItems value="#{referenceData.approveLeave}"/>
</h:selectOneMenu>
</h:column>
<p:column>
<f:facet name="header">Action</f:facet>
<p:commandButton value="Approve Leave" action="approveleave" id="approveleave" style="margin-left:250px;">
<f:setPropertyActionListener value="#{e}" target="#{employeeleave.selected}" /></p:commandButton>
</p:column>
</h:dataTable>
</h:form>
<h2>Please Apply for Leave Here</h2>
<h:form>
<h:panelGrid columns="3" id="leaveform" >
<h:outputLabel for="beds">Select the Type of the Leave</h:outputLabel>
<h:selectOneMenu id="leavetype" value="#{employeeLeave.type}">
<f:selectItems value="#{referenceData.leaveType}"/>
</h:selectOneMenu>
<div>
<h:outputLabel for="startDate">Start Date</h:outputLabel>
<p:calendar id="startDate" label="Start Date"
value="#{employeeLeave.startDate}" pattern="MM-dd-yyyy" timeZone="EST" required="true" />
</div>
<div>
<h:outputLabel for="endDate">End Date</h:outputLabel>
<p:calendar id="endDate" label="End Date"
value="#{employeeLeave.endDate}" pattern="MM-dd-yyyy" timeZone="EST" required="true" />
</div>
<div>
<h:outputLabel for="checkoutDate">Reason</h:outputLabel>
<h:inputTextarea id="reason" value="#{employeeLeave.reason}"
required="true"
label="reason" >
</h:inputTextarea>
</div>
</h:panelGrid>
<center><p:commandButton value="Apply Leave" action="applyleave" id="applyleave" style="margin-left:250px;"/></center>
</h:form>
<br></br>
<center> <h1 style="font-size: 16px;font-weight:bold;margin-top:100px;">Leave Application</h1></center>
</ui:define>
</ui:composition>
main-flow.xml
<action-state id="ApproveLeave">
<!-- <set name="viewScope.employeeleave" value="employeeleave.selected" /> -->
<evaluate expression="leaveBo.approveLeave(employeeLeave.selectedRow)"></evaluate>
<transition to="managerpage"></transition>
</action-state>
Here am trying to get the selected row and I try to evaluate it.
But I am getting the following error.
javax.el.ELException: /WEB-INF/flows/main/managerpage.xhtml #70,86 target="#{employeeleave.selected}": Cannot convert selected of type class java.lang.String to class java.lang.Integer
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:103)
at com.sun.faces.facelets.tag.jsf.core.SetPropertyActionListenerHandler$SetPropertyListener.processAction(SetPropertyActionListenerHandler.java:210)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at javax.faces.component.UIData.broadcast(UIData.java:1093)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:120)
at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:226)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196)
at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
As the error log says:
The method arguments for the setter setSelected need to be of type String in your case, like this:
public class Employeeleave {
public void setSelected(String newValue){
selected = newValue;
}
}
Related
I'm using a modal window to select a value. After i make a selection and open the modal window again. I want the modal list be filtered on the selectedValue.
It goes back to the front page.
and if open modal again and select 'ABC', it should look like this:
this is look up and which list should be put in modal xhtml:
<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"
xmlns:pe="http://primefaces.org/ui/extensions">
<p:panel id="dialog-content">
<h:form id="accountLookUpModal" style="width: 777px">
<p:panelGrid id="Info" columns="2" columnClasses="labelColumn,fieldColumn">
<!-- TYPE -->
<h:outputLabel id="AccountType" for="accountType" value="#{message['field.type']}" />
<p:selectOneMenu id="accountType" rendered="#{not empty account.criteria}" value="#{account.criteria.accountType}" converter="#{enumerationConverter}" disabled="#{account.disableLookUp}">
<p:ajax event="change" listener="#{account.filterOnType(true)}" update="#form, :dataTableForm"/>
<f:selectItems itemLabelEscaped="true" value="#{enumerationBean.getaccountTypeList()}" var="c" itemLabel="#{message[c.bundleKey]}" itemValue="#{c}"/>
</p:selectOneMenu>
</p:panelGrid>
</h:form>
<h:form id="dataTableForm" prependId="false" style="width:777px;">
<!-- INCLUDE Account Table -->
<ui:include src="/includes/accountLookUp.xhtml">
<ui:param name="PANEL_ID" value="accountActionPanel" />
<ui:param name="DT_ID" value="accountTable" />
<ui:param name="DT_DATA" value="#{account.accountTableLookUp}" />
<ui:param name="CR_BEAN" value="#{accountBean}" />
</ui:include>
</h:form>
</p:panel>
</ui:composition>
This is the xhtml used to select the update the list:
<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:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui">
<p:dataTable id="#{DT_ID}" var="acc" emptyMessage="" value="#{DT_DATA.values}" rowIndexVar="index"
paginator="true" selection="#{DT_DATA.selectedValues}" rows="8" paginatorPosition="top"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
editable="false" lazy="true" sortBy="#{acc.name}" sortOrder="ascending"
liveResize="true" filterDelay="100">
<p:ajax event="filter" listener="#{DT_DATA.onFilter}" />
<p:ajax event="rowToggle" listener="#{account.expandLookUp(acc)}" immediate="true"/>
<p:column styleClass="ui-column-rowtoggler" exportable="false">
<p:rowToggler id="cdtlu#{DT_ID}RT"/>
</p:column>
<!-- filterBy="#{acc.name}" -->
<p:column id="accountName" sortBy="#{acc.name}" filterBy="#{acc.name}" >
<f:facet name="header">
<h:outputText id="cu#{DT_ID}accountName" value="#{message['field.name']}" />
</f:facet>
<h:outputText id="cu#{DT_ID}accountName" value="#{acc.name}"/>
</p:column>
<!-- filterBy="#{acc.city}" -->
<p:column id="accountCity" sortBy="#{acc.city}" filterBy="#{acc.city}" >
<f:facet name="header">
<h:outputText id="cu#{DT_ID}accountCity" value="#{message['field.city']}" />
</f:facet>
<h:outputText id="cu#{DT_ID}accountCity" value="#{acc.city}" />
</p:column>
<!-- filterBy="#{acc.countryCode}" -->
<p:column id="accountCountry" sortBy="#{acc.countryCode}" filterOptions="#{enumerationBean.accountList}" filterBy="countryCode" >
<f:facet name="header">
<h:outputText id="cu#{DT_ID}CountryCode" value="#{message['field.countryCode']}" />
</f:facet>
<h:outputText id="cu#{DT_ID}TCountryCode" value="#{message[acc.countryCode.bundleKey]}" />
</p:column>
<p:column id="sel" styleClass="ui-column-rowtoggler">
<f:facet name="header">
<h:outputText id="cu#{DT_ID}Sel" value="#{message['common.sel']}" />
</f:facet>
<p:commandButton action="save-dialog" id="cu#{DT_ID}BtnSel"
actionListener="#{companySearchBean.updateCompanyOwner(acc)}"
icon="ui-icon ui-icon-e-w" >
</p:commandButton>
</p:column>
</p:dataTable>
</ui:composition>
Now i would like to filter with 'name' so that it looks it last picture. I used filterValue but then filterBy doesn't work properly and it produces null. In the nutshell if I select 'ABC' and then open the modal again. it should only contain list contain name like 'ABC'.
I'm new to prime faces so any help would be appreciated. Also i apologize for terrible diagrams.
I have an xhtml in which I wrap two model dialogs in one form ( I wrap the whole body ). As a result when I try to submit the content on one dialog, I get validation errors from the other dialog.
When I seperate the forms for each dialog, I get warnings regarding I should wrap the whole content under one form ( or so I have interpreted ).
What is the correct way to use form tag both under this example and in general ?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<f:view>
<h:head>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta http-equiv="Content-Type" content="text/html;charset=utf8"/>
</h:head>
<h:body id="templateBody">
<h:form id="userForm" prependId="false">
<p:messages id="mymessages" autoUpdate="true" showDetail="true"/>
<h:panelGrid columns="4" id="operationBtnsGrid">
<p:commandButton value="New" icon="ui-icon-plusthick" onclick="newDialog.show();"/>
<p:commandButton value="Update" update="dataTable" icon="ui-icon-pencil"
disabled="#{userController.userModels.selectedUser.id==null}"
onclick="updateDialog.show();"/>
<p:commandButton id="Delete" value="Delete" update="dataTable" onclick="confirmation.show()"
icon="ui-icon-trash" disabled="#{userController.userModels.selectedUser.id==null}"/>
</h:panelGrid>
<p:dataTable id="dataTable"
var="user"
value="#{userController.findAll()}"
rowKey="#{user.id}"
selectionMode="single"
selection="#{userController.userModels.selectedUser}">
<f:facet name="header">
<h:outputText value="User List"/>
</f:facet>
<p:ajax event="rowSelect" update="#(form)"/>
<p:column>
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<h:outputText value="#{user.name}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Lastname"/>
</f:facet>
<h:outputText value="#{user.lastname}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Phone Number"/>
</f:facet>
<h:outputText value="#{user.phoneNumber}"/>
</p:column>
</p:dataTable>
<p:dialog header="Add New User" widgetVar="newDialog" modal="true">
<p:panelGrid columns="2">
<h:outputLabel for="new_name" value="Name: "/>
<p:inputText id="new_name" required="true" value="#{userController.userModels.newUser.name}"/>
<h:outputLabel for="new_lastname" value="Lastname: "/>
<p:inputText id="new_lastname" required="true" value="#{userController.userModels.newUser.lastname}"/>
<h:outputLabel for="new_phoneNumber" value="Phone number: "/>
<p:inputMask id="new_phoneNumber" value="#{userController.userModels.newUser.phoneNumber}" mask="(999) 999-9999"/>
</p:panelGrid>
<p:panelGrid columns="1">
<p:captcha label="Captcha" language="en" theme="white"/>
</p:panelGrid>
<p:commandButton id="saveNewButton" actionListener="#{userController.addNewUser}"
oncomplete="confirmation.hide()" update="#(form), #(#mymessages)" value="Save"
ajax = "false" icon="ui-icon-check"/>
</p:dialog>
<p:dialog header="Update User" widgetVar="updateDialog" modal="true">
<p:panelGrid columns="2">
<h:outputLabel for="update_name" value="Name: "/>
<p:inputText id="update_name" required="true" value="#{userController.userModels.selectedUser.name}"/>
<h:outputLabel for="update_lastname" value="Lastname: "/>
<p:inputText id="update_lastname" required="true" value="#{userController.userModels.selectedUser.lastname}"/>
<h:outputLabel for="update_phoneNumber" value="Phone number: "/>
<p:inputMask id="update_phoneNumber" value="#{userController.userModels.selectedUser.phoneNumber}" mask="(999) 999-9999"/>
</p:panelGrid>
<p:commandButton id="updateSelectedButton" actionListener="#{userController.updateUser}"
oncomplete="confirmation.hide()" update="#(form), #(#mymessages)" value="Save"
ajax = "false" icon="ui-icon-check"/>
</p:dialog>
<p:confirmDialog id="confirmDialog" message="Silmek istediğinizden emin misiniz ?"
header="Silmek için onayınız gerekiyor" severity="alert" widgetVar="confirmation">
<p:commandButton id="confirm" value="Evet" oncomplete="confirmation.hide()"
actionListener="#{userController.deleteUser}"
ajax = "false" update="#(form), #(#mymessages)"/>
<p:commandButton id="decline" value="Hayır" onclick="confirmation.hide()" type="button"/>
</p:confirmDialog>
</h:form>
<p:ajaxStatus style="width:64px;height:64px;position:fixed;right:5px;bottom:5px">
<f:facet name="start">
<p:graphicImage value="/images/ajax-loader.gif" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
</h:body>
</f:view>
</html>
When you do a form submit it submits the whole form and all ids, you have them all on the page so they fail validations.
You can either:
A) Use 'rendered' on your div blocks to hide them from the dom based on conditions, but not likely due to you wanting to have an update/new - its kind of difficult.
B) use PPR (Partial Tree Processing)
http://www.primefaces.org/showcase/ui/pprPartialTree.jsf
On your commandbutton - add 'process="update_name, update_lastname, update_phoneNumber"'
This will only submit those fields to be updated, or if you wrap them in a block with an id you can just do process="blockToUpdate"
I'm trying to render validation messages. The trick I'm working on is that the messages appear only after pressing Enter key (not after submit button!). After that it works correctly.
Here's what I did at the JSF side (some parts have been omitted for simplicity) :
<?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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:sec="http://www.springframework.org/security/facelets/tags"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<body>
<ui:composition>
<h:form id="idForm">
<h:panelGrid width="100%"
rendered="#{not empty declarationReglementaireModel.detailCurrentDecReg.decReg.listLigneGldsDTO}">
<rich:extendedDataTable id="listGLD" iterationStatusVar="itGLD"
rows="50"
value="#{declarationReglementaireModel.detailCurrentDecReg.decReg.listLigneGldsDTO}"
var="ligneGLD" frozenColumns="1" style="height:300px; width:920px;"
selectionMode="none">
<rich:column width="35px">
<h:panelGrid columns="1" cellpadding="2">
<a4j:commandLink render="editGridGLD" execute="#this"
oncomplete="#{rich:component('modifGLD')}.show()">
<span class="icone icone-edit icone-align-center" />
<a4j:param value="#{itGLD.index}"
assignTo="#{declarationReglementaireModel.currentLigneGldIndex}" />
<f:setPropertyActionListener
target="#{declarationReglementaireModel.currentLigneGld}"
value="#{ligneGLD}" />
</a4j:commandLink>
</h:panelGrid>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Montant encaissement exercice" />
</f:facet>
<div style="text-align: right">
<h:outputText value="#{ligneGLD.mtEncaissesExercice}">
<f:convertNumber currencySymbol="€" groupingUsed="true"
maxFractionDigits="2" type="currency" />
</h:outputText>
</div>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Montant réductions exercice" />
</f:facet>
<div style="text-align: right">
<h:outputText value="#{ligneGLD.mtReducExercice}">
<f:convertNumber currencySymbol="€" groupingUsed="true"
maxFractionDigits="2" type="currency" />
</h:outputText>
</div>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Date PACA" />
</f:facet>
<h:outputText value="#{ligneGLD.dtPaca}">
<f:convertDateTime pattern="dd/MM/yyyy" timeZone="Europe/Paris" />
</h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Numéro OLAF" />
</f:facet>
<h:outputText value="#{ligneGLD.noOlaf}">
</h:outputText>
</rich:column>
<rich:column width="200px">
<f:facet name="header">
<h:outputText value="Origine titre" />
</f:facet>
<h:outputText value="#{ligneGLD.origineTitre}">
</h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="Contentieux" />
</f:facet>
<h:outputText value="#{ligneGLD.boContentieux}">
</h:outputText>
</rich:column>
</rich:extendedDataTable>
<h:panelGrid columns="3" styleClass="liste">
<h:panelGroup>
<h:outputText id="paginationCompteurGLD"
value="Ligne #{composantPaginationGLDBack.firstElement} à #{composantPaginationGLDBack.lastElement} sur #{composantPaginationGLDBack.nbTotalElements}" />
</h:panelGroup>
</h:panelGrid>
</h:panelGrid>
<rich:popupPanel header="Données modifiables" id="modifGLD"
domElementAttachment="form" autosized="true" zindex="500"
left="auto" top="auto">
<h:panelGrid columns="1" id="editGridGLD">
<h:panelGroup styleClass="bloc-contenu-message " layout="block">
<rich:messages />
</h:panelGroup>
<h:panelGrid columns="6" cellspacing="10"
styleClass="criteresSaisie" rowClasses="critereLigne"
columnClasses="titreCourtColonne,,titreCourtColonne,,titreCourtColonne,">
<h:outputLabel for="GLDdtDeclCreanceMandataire"
value="Date déclaration mandataire" />
<rich:calendar id="GLDdtDeclCreanceMandataire" inputSize="8"
value="#{declarationReglementaireModel.currentLigneGld.dtDeclCreanceMandataire}"
enableManualInput="true" datePattern="dd/MM/yyyy"
showInput="true">
</rich:calendar>
<h:outputLabel value="Montant réductions exercice" />
<h:inputText
value="#{declarationReglementaireModel.currentLigneGld.mtReducExercice}"
onchange="this.value=this.value.replace(/\./g,',')" size="10">
<f:convertNumber maxFractionDigits="2" type="number" />
</h:inputText>
<h:outputLabel for="GLDdtPaca" value="Date PACA" />
<rich:calendar id="GLDdtPaca" inputSize="8"
value="#{declarationReglementaireModel.currentLigneGld.dtPaca}"
enableManualInput="true" datePattern="dd/MM/yyyy"
showInput="true">
</rich:calendar>
</h:panelGrid>
<h:panelGroup>
<div align="right">
<h:panelGrid columns="8">
<a4j:commandButton value="Enregistrer"
action="#{rechercheDecRgltCtrl.enregistrerLigneGLD}"
render="editGridGLD" execute="modifGLD"
oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('modifGLD')}.hide();}" />
<a4j:commandButton value="Annuler"
onclick="#{rich:component('modifGLD')}.hide(); return false;" />
</h:panelGrid>
</div>
</h:panelGroup>
</h:panelGrid>
</rich:popupPanel>
</h:form>
</ui:composition>
</body>
</html>
You can use a4j:support to sent request when you want,
like onblur / onkeyup ... or any javascript the item supported.
http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_support.html
Action method is not working in my <p:menuitem>. I would like to change activeIndex via an action method of <p:menuitem>.
The code below is the code on template page that is used in my pages:
<h:form>
<p:tabMenu activeIndex="#{loginBean.activeindex}">
<p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star" />
<p:menuitem value="Fabricants" url="/pagess/pagesFabricant/Fabricant.jsf" icon="ui-icon-wrench" action="#{loginBean.Dirige(1)}" />
<p:menuitem value="Composants" url="/pagess/pagesComposant/Composant.jsf" icon="ui-icon-search" action="#{loginBean.Dirige(2)}"/>
<p:menuitem value="Dossier d'equivalence" url="DEQ.jsf" icon="ui-icon-document" action="#{loginBean.Dirige(3)}"/>
</p:tabMenu>
</h:form>
This is my bean:
public class LoginBean {
private int activeindex;
public int getActiveindex() {
return activeindex;
}
public void setActiveindex(int activeindex) {
this.activeindex = activeindex;
}
public void Dirige(int a){
setActiveindex(a);
}
}
When I click on any menu item the action method is not called. I did some debugging to ensure that the method is not called. Alternatively, the method is working with <p:commandButton>.
This is the template
<!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:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<ui:insert name="title">Title</ui:insert></title>
</h:head>
<h:body>
<h:form>
<p:tabMenu activeIndex="#{loginBean.activeindex}">
<p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star" />
<p:menuitem value="Fabricants" url="/pagess/pagesFabricant/Fabricant.jsf" icon="ui-icon-wrench" action="#{loginBean.Dirige(1)}" />
<p:menuitem value="Composants" url="/pagess/pagesComposant/Composant.jsf" icon="ui-icon-search" action="#{loginBean.Dirige(2)}"/>
<p:menuitem value="Dossier d'equivalence" url="DEQ.jsf" icon="ui-icon-document" action="#{loginBean.Dirige(3)}"/>
</p:tabMenu>
</h:form>
<p/>
<table border="5" align="center">
<tr><th class="title">
Bienvenue #{loginBean.username} dans Notre application Ipertool
</th></tr>
</table><p/>
<ui:insert name="body">Body</ui:insert>
<p:separator id="separator"/>
<ui:include src="/templates/includes/footer.xhtml"/>
</h:body>
</html>
This is page Fabricant when I press menuitem Fabricant
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/templates/template.xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:define name="title">Liste Fabricants</ui:define>
<ui:define name="body">
<h:form id="form">
<p:growl id="growl" showDetail="true"/>
<p:commandLink value="Ajouter Fabricant" action="#{fabricantbean.Ajouter()}"><img src="/image/ajout.jpg" alt= "Ajouter"></img></p:commandLink>
<p:dataTable id="cars" var="fab" value="#{fabricantbean.list}" paginator="true" rows="10" rowKey="#{fab.idFabricant}"
selection="#{fabricantbean.selectitem}" selectionMode="single" emptyMessage="Aucun Fabricants Trouve">
<p:ajax event="rowSelect" listener="#{fabricantbean.onRowSelect}"
update=":form:dialog :form:growl" oncomplete="carDialog.show()" />
<p:column id="modelColumn" filterBy="#{fab.nomFabricant}"
headerText="Nom Fabricant" footerText="contains"
filterMatchMode="contains">
<h:outputText value="#{fab.nomFabricant}" />
</p:column>
<p:column>
<f:facet name="header">
Lien Site
</f:facet>
<h:outputText value="#{fab.lienSite}" />
</p:column>
<p:column>
<f:facet name="header">
Staut Fabricant
</f:facet>
<h:outputText value="#{fab.statutFabricant}" />
</p:column>
<p:column>
<f:facet name="header">
Nom Contact
</f:facet>
<h:outputText value="#{fab.nomContact}" />
</p:column>
<p:column>
<f:facet name="header">
Mail Contact
</f:facet>
<h:outputText value="#{fab.mailContact}" />
</p:column>
<p:column>
<f:facet name="header">
Action
</f:facet>
<p:commandButton value="Modifier" action="#{fabricantbean.Modifier()}">
<f:setPropertyActionListener target="#{fabricantbean.selectitem}" value="#{fab}" />
</p:commandButton>
<p:commandButton value="Supprimer" onclick="info.show()" >
<f:setPropertyActionListener target="#{fabricantbean.selectitem}" value="#{fab}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:confirmDialog id="infodialoge" message="Si vous supprimer ce Fabricant vous resquer de supprimer ces composant ainsi les DEQ"
header="supprimer Fabricant" severity="alert" widgetVar="info">
<p:commandButton id="confirm" value="Oui Sure" oncomplete="info.hide()"
action="#{fabricantbean.supprimer()}" update="form:cars"/>
<p:commandButton id="decline" value="Non " onclick="info.hide()" type="button" />
</p:confirmDialog>
<p:dialog id="dialog" header="Fabricant Detail" widgetVar="carDialog" resizable="false" dynamic="true"
showEffect="fade" hideEffect="explode">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="/images/cars/#{tableBean.selectedCar.manufacturer}.jpg"/>
</f:facet>
<h:outputText value="lien Reach:" />
<h:outputText value="#{fabricantbean.selectitem.lienReach}" />
<h:outputText value="lien Fmd:" />
<h:outputText value="#{fabricantbean.selectitem.lienFmd}" />
<h:outputText value="lien Rohs:" />
<h:outputText value="#{fabricantbean.selectitem.lienRohs}" />
<h:outputText value="lien cofc:" />
<h:outputText value="#{fabricantbean.selectitem.fichierCofc}" />
<h:outputText value="remarque:" />
<h:outputText value="#{fabricantbean.selectitem.remarqueFabricant}" />
</h:panelGrid>
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
the problem is in fact the url in your menuitem.
You have to edit your Dirige method.
Try the following:
public String Dirige(int a){
setActiveindex(a);
if (a == 1) {
return "/pagess/pagesFabricant/Fabricant.jsf";
}else{
if (a == 2) {
return "/pagess/pagesComposant/Composant.jsf";
}else{
...
}
}
}
and in your template you have to remove the url-Tags:
<h:form>
<p:tabMenu activeIndex="#{loginBean.activeindex}">
<p:menuitem value="Home" url="Menu.jsf" icon="ui-icon-star" />
<p:menuitem value="Fabricants" icon="ui-icon-wrench" action="#{loginBean.Dirige(1)}" />
<p:menuitem value="Composants" icon="ui-icon-search" action="#{loginBean.Dirige(2)}"/>
<p:menuitem value="Dossier d'equivalence" icon="ui-icon-document" action="#{loginBean.Dirige(3)}"/>
</p:tabMenu>
</h:form>
Trying to do some simple primefaces datatable ajax work and get the following exception:
javax.servlet.ServletException: /default.xhtml #17,76 Parent not an instance of ClientBehaviorHolder: org.primefaces.component.datatable.DataTable#5fdb7adc
I'm using primefaces 3.3.1. My .xhtml code is here (I copied some of it from the primefaces site to see if I could get this working), anybody got any ideas?
<html xmlns="http://www.w3c.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui" >
<h:head>
</h:head>
<h:body>
<center>
<h:form id="form">
<p:dataTable id="personTable" var="client" value="#{tableBean.persons}"
selection="#{tableBean.person}" selectionMode="single">
<p:ajax event="rowSelect" listener="#{tableBean.onUserSelect}"
update=":form:displayf" oncomplete="carDialog.show()" />
<p:ajax event="rowUnselect"
listener="#{tableBean.onUserUnselect}"
update=":form:displayf" />
<f:facet name="header">
Click "View" button after selecting a row to see details
</f:facet>
<p:column headerText="Name">
#{client.name}
</p:column>
<p:column headerText="Address">
#{client.address}
</p:column>
<p:column headerText="Phone" >
#{client.phone}
</p:column>
</p:dataTable>
<p:dialog id="dialog" header="Car Detail" widgetVar="carDialog" resizable="false"
showEffect="explode" hideEffect="explode">
<h:panelGrid id="displayf" columns="2" cellpadding="4">
<h:outputText value="Name:" />
<h:outputText value="#{tableBean.person.name}" />
<h:outputText value="Address:" />
<h:outputText value="#{tableBean.person.address}" />
<h:outputText value="Phone:" />
<h:outputText value="#{tableBean.person.phone}" />
</h:panelGrid>
</p:dialog>
</h:form>
</center>
</h:body>
</html>