Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
What is the way to refresh page in primefaces?
I have tried
<p:commandLink actionListener="#{legendcontroller.addEditLegendType(true,false)}" update="legendform:pnlform" >Add Legend</p:commandLink>
<p:commandLink immediate="true" actionListener="#{legendcontroller.addEditLegendType(false,false)}" update="legendform:pnlform" >View Legend </p:commandLink>
<p:commandLink id="editLink" value="Edit" actionListener="#{legendcontroller.editLegendType(legendtype)}" update=":legendform:pnlform" process="#this"/>
The third one would generate error in page with datatable. The error I get:
Cannot find component with expression "pnlform" referenced from "j_idt22:legendviewdatatable:0:editLink". I would like to refresh the form when I hit edit and open editpanel. And I would like to refresh only datatable when I hit delete.
The full html:
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
>
<h:head>
<title>Legend</title>
</h:head>
<h:body>
<ui:composition template="/generalTemplate.xhtml">
<ui:define name="title">Legend </ui:define>
<ui:define name="content" >
<f:view>
<h:form id="legendform" prependId="false" >
<p:panel id="pnlform">
<f:facet name="header">
<p:commandLink actionListener="#{legendcontroller.addEditLegendType(true,false)}" update="legendform:pnlform" >Add Legend</p:commandLink>
<p:commandLink immediate="true" actionListener="#{legendcontroller.addEditLegendType(false,false)}" update="legendform:pnlform" >View Legend </p:commandLink>
</f:facet>
<p:panel id="addeditpnl" rendered="#{legendcontroller.addLegendBool or legendcontroller.editLegendBool}" style="width:100%">
<h:panelGrid columns="2" >
<h:outputLabel value="Legend Name" for="legendname" />
<h:inputText id="legendname" value="#{legendcontroller.legendType.legendname}" title="Legendname" required="true" requiredMessage="The Legendname field is required."/>
<h:outputLabel value="Legend Description" for="legendDesc" />
<h:inputText id="legendDesc" value="#{legendcontroller.legendType.legendDesc}" title="LegendDesc" />
<h:outputLabel value="Legend For" for="legendfor" />
<h:inputText id="legendfor" value="#{legendcontroller.legendType.legendfor}" title="Legendfor" required="true" requiredMessage="The Legendfor field is required."/>
</h:panelGrid>
<p:dataTable id="addeditdtable" value="#{legendcontroller.legendType.legendList}" var="legend" style="width:100%">
<p:column>
<f:facet name="header">
<h:outputText value="Legend SN"/>
</f:facet>
<h:inputText value="#{legend.legendSn}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="LegendDesc"/>
</f:facet>
<h:inputText value="#{legend.legendDesc}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Lower Range"/>
</f:facet>
<h:inputText value="#{legend.lowerrange}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Upper Range"/>
</f:facet>
<h:inputText value="#{legend.upperrange}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Color"/>
</f:facet>
<p:colorPicker value="#{legend.color}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="ADD/Delete"/>
</f:facet>
<p:commandLink value="Add" actionListener="#{legendcontroller.addLegendAfter(legend)}" update="addeditdtable" process="#this"/>
<h:outputText value=" / "/>
<p:commandLink value="Delete" actionListener="#{legendcontroller.removeLegendDTO(legend)}" update="addeditdtable" process="#this"/>
</p:column>
<f:facet name="footer">
<p:commandButton value="SAVE" action="#{legendcontroller.saveLegend()}"/>
</f:facet>
</p:dataTable>
</p:panel>
<p:dataTable id="legendviewdatatable" value="#{legendcontroller.allLegendType()}" rendered="#{!legendcontroller.addLegendBool and !legendcontroller.editLegendBool}" var="legendtype" style="width:100%">
<p:column>
<f:facet name="header">
<h:outputText value="Legendname"/>
</f:facet>
<h:outputText value="#{legendtype.legendname}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="LegendDesc"/>
</f:facet>
<h:outputText value="#{legendtype.legendDesc}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Legendfor"/>
</f:facet>
<h:outputText value="#{legendtype.legendfor}"/>
</p:column>
<p:column id="editDelCol">
<f:facet name="header">
<h:outputText value="Edit/Delete"/>
</f:facet>
<p:commandLink id="editLink" value="Edit" actionListener="#{legendcontroller.editLegendType(legendtype)}" update=":legendform:pnlform" process="#this"/>
<h:outputText value=" / "/>
<p:commandLink id="deleteLink" value="Delete" actionListener="#{legendcontroller.deleteLegendType(legendtype)}" update="legendviewdatatable" process="#this" />
</p:column>
</p:dataTable>
</p:panel>
</h:form>
</f:view>
</ui:define>
</ui:composition >
</h:body>
</html>
Finally I found that primefaces is not taking the id gave but is using random id:
<form id="j_idt12" name="j_idt12" method="post" action="/Configuration/LegendManager/LegendType.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt12" value="j_idt12">
<div id="j_idt12:j_idt13" class="ui-toolbar ui-widget ui-widget-header ui-corner-all ui-helper-clearfix"><div class="ui-toolbar-group-left"><button id="j_idt12:j_idt15" name="j_idt12:j_idt15" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" title="Welcome" type="submit" role="button" aria-disabled="false"><span class="ui-button-icon-left ui-icon ui-c ui-icon-disk"></span><span class="ui-button-text ui-c">Home</span></button><button id="j_idt12:j_idt16" name="j_idt12:j_idt16" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" title="Configuration" type="submit" role="button" aria-disabled="false"><span class="ui-button-icon-left ui-icon ui-c ui-icon-disk"></span><span class="ui-button-text ui-c">Configuration</span></button></div><div class="ui-toolbar-group-right"><span id="j_idt12:j_idt18" class="ui-menubutton"><button id="j_idt12:j_idt18_button" name="j_idt12:j_idt18_button" type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-left" role="button" aria-disabled="false"><span class="ui-button-icon-left ui-icon ui-c ui-icon-triangle-1-s"></span><span class="ui-button-text ui-c">sugandha</span></button></span></div></div><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="2044288989474132123:952602282947229034" autocomplete="off">
</form>
Since you used prependId="false", you should use update="pnlform" only, or remove prependId="false" so you will be able to keep update="yourformname:yourid" or update=":yourid".
More info :
h:form
change your code as follow: <h:form id="legendform" prependId="true" > or without prependId attribute then reference to nested component inside this form with update=":legendform:pnlform" attribute from every where else.
in your case if you want to set prependId=false and then reference from nested components inside <datatable> in same form you should update withupdate=":pnlform".
this is because <datatable> has own NamingContainer
Related
This question already has answers here:
How to show details of current row from p:dataTable in a p:dialog and update after save
(1 answer)
p:resetInput does not reset the p:dialog when it is reopened
(1 answer)
Closed 2 years ago.
I have a problem with resetting the values of a <p: selectOneMenu> component that is housed within a <p: dialog> component, it turns out that I have declared the <p: dialog> on the same page where I show it with a < p: commandButton> and I want that when I finish editing the data and press the button again, the component <p: selectOneMenu> comes out with the initial values, and this is not happening, instead it keeps the selection I made previously. Thank you very much for the help you can give me. this is the code of the page. I don't think it is necessary to put the code for the backing beans but they do need it without problem.
<?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://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<body class="areaContenido">
<ui:composition template="../resources/template/tgeneral.xhtml">
<ui:define name="content" class="areaContenido">
<h:form id="guser">
<p:growl id="msgs" showDetail="true" />
<p:dataTable var="usermio" value="#{userBean.lazyModel}" paginator="true" rows="10" class="FuentTable" rowKey="#{usermio.id}"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" id="userTable" lazy="true">
<f:facet name="header">
<p:outputLabel value="Gestión de usuarios del sistema" style="font-weight: bold; text-align: center;"/>
</f:facet>
<p:column headerText="Id" width="5%">
<h:outputText value="#{usermio.id}" />
</p:column>
<p:column headerText="Usuario" width="15%" >
<h:outputText value="#{usermio.usuario}" />
</p:column>
<p:column headerText="Nombre" width="20%">
<h:outputText value="#{usermio.nombre}"/>
</p:column>
<p:column headerText="Apellidos" width="25%">
<h:outputText value="#{usermio.apellidos}" />
</p:column>
<p:column headerText="Rol" width="15%">
<h:outputText value="#{usermio.rol.rol}" />
</p:column>
<p:column headerText="Opt" width="15%">
<p:commandButton value="" update=":guser:userEdit" onclick="PF('userDial').show()" icon="ui-icon-pencil" ajax="true" >
<f:setPropertyActionListener value="#{usermio}" target="#{userBean.selecteduser}" />
</p:commandButton>
<p:commandButton value="" update=":guser:userEdit" onclick="PF('cd').show()" icon="ui-icon-key" ajax="true">
<f:setPropertyActionListener value="#{usermio}" target="#{userBean.selecteduser}" />
</p:commandButton>
<p:commandButton value="" update=":guser:userEdit" onclick="PF('cd').show()" icon="ui-icon-cancel" ajax="true">
<f:setPropertyActionListener value="#{usermio}" target="#{userBean.selecteduser}" />
</p:commandButton>
</p:column>
<f:facet name="footer">
<p:button icon="ui-icon-plus" id="nuevo" value="Nuevo" href="/glitic/adm/register.xhtml" title="Nuevo usuario" />
</f:facet>
</p:dataTable>
<p:dialog header="Edición de datos" widgetVar="userDial" modal="true" showEffect="bounce" hideEffect="fade" resizable="false" class="Fuent" responsive="true" >
<p:outputPanel id="userEdit" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty userBean.selecteduser}" columnClasses="label,value">
<h:outputText value="Id:" />
<h:outputText value="#{userBean.selecteduser.id}" />
<h:outputText value="Usuario" />
<p:inputText value="#{userBean.selecteduser.usuario}" id="username" required="true" requiredMessage="Se necesita el usuario"/>
<h:outputText value="Nombres" />
<p:inputText value="#{userBean.selecteduser.nombre}" id="nombre" required="true" requiredMessage="Se necesita el nombre"/>
<h:outputText value="Apellidos" />
<p:inputText value="#{userBean.selecteduser.apellidos}" id="apellidos" required="true" requiredMessage="Se necesita los apellidos"/>
<h:outputText value="Rol" />
<p:selectOneMenu id="sroles" value="#{userBean.selectedrol}" style="width:160px" effect="fold" >
<f:selectItem itemLabel="Escoja un rol para el usuario" itemValue="" />
<f:selectItems value="#{userBean.roles}" var="xroles" itemLabel="#{xroles.rol}" itemValue="#{xroles.id}" />
</p:selectOneMenu>
<h:outputText value="Guardar cambios:" />
<p:commandButton value="Guardar" action="#{cttobean.NVenta()}" ajax="false"/>
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
I am starting developpment with JSF and PrimeFace datatable. I have prepared the following xhtml page:
<!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:p="http://primefaces.org/ui">
<h:head>
<title>Find Capital of Countries</title>
</h:head>
<h:body>
<h:form id="FrmTest">
<p:dataTable id="ListSites" value="#{testing.SiteSearch()}" var="lst" editable="true">
<f:facet name="header">
List of Sites
</f:facet>
<p:column>
<f:facet name="header">
Site Code
</f:facet>
#{lst.stCode}
</p:column>
<p:column headerText="Site Description">
<h:outputText value="#{lst.stDescription}" />
</p:column>
<p:column headerText="is Active">
<div style="text-align: center;">
<p:selectBooleanCheckbox value="#{lst.stActive}" />
</div>
</p:column>
<p:column>
<f:facet name="header">
Site Active
</f:facet>
<div style="text-align: center;">
<h:outputText value= "#{lst.stActive}" />
</div>
</p:column>
<p:column>
<f:facet name="header">
Modified By
</f:facet>
#{lst.modifiedBy}
</p:column>
<p:column>
<f:facet name="header">
Modification Date
</f:facet>
#{lst.modifiedDate}
</p:column>
<p:column>
<f:facet name="header">
Has Error
</f:facet>
#{lst.hasError}
</p:column>
<p:column>
<f:facet name="header">
Error Description
</f:facet>
#{lst.errorDescription}
</p:column>
<p:column>
<f:facet name="header">
Row State
</f:facet>
#{lst.rowState}
</p:column>
</p:dataTable>
<h:outputLabel value="Enter Country Name:"/>
<h:inputText id="country" binding="#{testing.country}"
valueChangeListener="#{testing.findCapitalListener}"
immediate="true"
onchange="document.getElementById('findcapital').click();" />
<br/>
<br/>
<h:outputLabel value="Capital is: " />
<h:inputText id="capital" binding="#{testing.capital}" immediate="true"/>
<br/>
<br/>
<h:commandButton value="Submit" partialSubmit="true" />
<div style="visibility: hidden" >
<h:commandButton id="findcapital" value="findcapital" partialSubmit="true" immediate="true" />
</div>
</h:form>
</h:body>
</html>
I want entry made in text box named country to update datatable named ListSites. The associated listener is called (system.out.println made) but the primeface update is not made. Here is the listener:
```
public void findCapitalListener(ValueChangeEvent cdl) {
String country = cdl.getNewValue().toString();
System.out.println("Country is : " + country);
StringBuilder capitalCountry = new StringBuilder();
findCapital(country, capitalCountry);
capital.setValue(capitalCountry.toString());
siteDto = listSiteDto.get(0);
siteDto.setStDescription(capitalCountry.toString());
listSiteDto.set(0, siteDto);
PrimeFaces.current().ajax().update("FrmTest:ListSites");
//System.out.println("Capital is : " + capital.getValue());
//System.out.println("New DTO Description : " + siteDto.getStDescription());
System.out.println("New list Description : " + listSiteDto.get(0).getStDescription());
}
```
The problem was due to the fact that the function populating the datatable (SiteSearch()) was retrieving data from the database. At that stage I wanted to refresh the page display before updating the database. I replaced the function by the list getter, things are working properly now.
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
I'm currently working with a PrimeFaces dataTable and am trying endlessly to append a new to the dataTable immediately after the user adds it. Server-side, everything is working -- data is saved to both the database and hard disk. I'd like to see a partial-page update following the successful request, and I just can't seem to get it to work. Here is my XHTML code:
<div class="content">
<div id="mainContent">
<div class="topNav">
<h:form id="navForm">
<p:commandButton value="Upload"/>
<p:commandButton value="New Folder" onclick="createDlg.show();" />
<p:commandButton value="Delete Folder" action="#" />
</h:form>
</div>
<div id="filePanel">
<h:form id="dataTable" prependId="false">
<p:dialog header="Create" widgetVar="createDlg" modal="true" height="200">
<p:panel header="New Folder">
<h:panelGrid columns="2">
<h:outputLabel value="Name:" for="txt_name"></h:outputLabel>
<p:inputText id="txt_name" value="#{directoryController.newDir.name}" required="true" />
<p:commandButton value="Create" actionListener="#{directoryController.createNew}" update="dGrid" oncomplete="createDlg.hide();"/>
<p:ajaxStatus style="width:16px; height:16px;">
<f:facet name="start">
<h:outputText value="Saving..." />
</f:facet>
<f:facet name="">
<h:outputText value="Complete." />
</f:facet>
</p:ajaxStatus>
</h:panelGrid>
</p:panel>
</p:dialog>
<p:dataTable id="dGrid" value="#{directoryController.itemsByOwner}" var="dir">
<p:column selectionMode="multiple"/>
<p:column sortBy="#{dir.name}">
<f:facet name="header">
File Name
</f:facet>
<h:outputText value="#{dir.name}" />
</p:column>
<p:column>
<f:facet name="header">
File Size
</f:facet>
</p:column>
</p:dataTable>
</h:form>
</div>
</div>
</div>
And finally, here is my backing bean.
public String createNew(){
newDir.setDateCreated(new Date());
newDir.setDateModified(new Date());
newDir.setId(BigDecimal.ZERO);
newDir.setLocation(ROOT_DIRECTORY + currentUser.getUsername() + "/");
newDir.setFilesCollection(f);
newDir.setDescription("");
newDir.setOwner(currentUser);
current = newDir;
create();
persistDirectoryFromObject(newDir);
newDir = new Directory();
RequestContext.getCurrentInstance().addPartialUpdateTarget("dGrid");
return null;
}
If you are using 3.0.M4 you could do:
...
...
<p:outputPanel autoUpdate="true">
<p:dataTable id="dGrid" value="#{directoryController.itemsByOwner}" var="dir">
<p:column selectionMode="multiple"/>
<p:column sortBy="#{dir.name}">
<f:facet name="header">
File Name
</f:facet>
<h:outputText value="#{dir.name}" />
</p:column>
<p:column>
<f:facet name="header">
File Size
</f:facet>
</p:column>
</p:dataTable>
</p:outputPanel>
or you could simply:
<p:commandButton value="Create" action="#{directoryController.createNew}" oncomplete="createDlg.hide();" ajax="false" />