f:ajax render does not update components anymore - jsf

I have a datatable and I load a modal for Edit data. But when I Edit and render the datatable nothing changed.
I mean I have a datatable and actions like delete and edit. When I press on edit I open modal then I edit the data on this modal then press Edit. As you see I make render for datatable but I can't see any changes in the datatable
<h:form id="branchesForm">
<h:panelGroup layout="block" class="box-header">
<h3 class="box-title">Branches</h3>
<h:commandButton value="Add New Branch" id="createBranchBtn" pt:data-loading-text="Loading..." pt:autocomplete="off" class="btn btn-primary sye-action-btn-loading">
<f:param name="pageType" value="create"/>
</h:commandButton>
</h:panelGroup>
<h:panelGroup layout="block" class="box-body table-responsive no-padding branches-datatable">
<div class="SYE-modal"> </div>
<h:panelGroup id="branchesListDiv" layout="block" class="container-fluid">
<h:dataTable id="example1" binding="#{index}" class="table table-hover table-bordered table-striped" value="#{branchesMB.list}" var="branch">
<h:column>
<f:facet name="header" >
<h:outputText value="#"/>
</f:facet>
<h:outputText value="#{index.rowIndex+1}"/>
<f:facet name="footer" >
<b><h:outputText value="#"/></b>
</f:facet>
</h:column>
<h:column >
<f:facet name="header">
<h:outputText value="Branch Name"/>
</f:facet>
<h:outputText value="#{branch.branchName}"/>
<f:facet name="footer">
<b><h:outputText value="Branch Name"/></b>
</f:facet>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Address"/>
</f:facet>
<h:outputText value="#{branch.branchAddress}"/>
<f:facet name="footer">
<b><h:outputText value="Address"/></b>
</f:facet>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Abbreviation"/>
</f:facet>
<h:outputText value="#{branch.branchAbbreviation}"/>
<f:facet name="footer">
<b><h:outputText value="Abbreviation"/></b>
</f:facet>
</h:column>
<h:column headerClass="syeActionDatatable">
<f:facet name="header">
<h:outputText value="Action"/>
</f:facet>
<f:facet name="footer">
<b><h:outputText value="Action"/></b>
</f:facet>
<div class="btn-group" >
<a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
<i class="glyphicon glyphicon-cog"></i>
<span class="caret"></span>
</a>
<ul class='dropdown-menu pull-right'>
<li>
<!--pt:data-toggle="modal" pt:data-target=".bs-example-modal-lg"-->
<h:commandLink actionListener="#{branchesMB.setEntityEditObject(branch)}" class="editDatatable" >
<f:ajax onevent="load" onerror="load" render=":branchesForm:branchEditArea"/>
<i class='glyphicon glyphicon-pencil'></i>
Edit
</h:commandLink>
</li>
<li>
<!--onclick="if (!confirm('Are you sure you want to delete this record?')) return false"-->
<h:commandLink action="#{branchesMB.destroy()}" onclick="if (!confirm('Are you sure you want to delete this record?'))
return false;">
<f:ajax render=":branchesForm:branchEditArea"/>
<f:setPropertyActionListener target="#{branchesMB.entityDeleteObject}" value="#{branch}"/>
<i class='glyphicon glyphicon-trash'></i>
Delete
</h:commandLink>
</li>
</ul>
</div>
</h:column>
</h:dataTable>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Edit Branch</h4>
</div>
<div class="modal-body">
<h:panelGroup id="branchEditArea" layout="block" class="box-body">
<ui:include src="/view/includes/messages.xhtml"/>
<h:inputHidden value="#{branchesMB.entityEditObject}" converter="BranchesConverter"/>
<h:panelGroup id="branchNameDiv" layout="block" class="form-group">
<h:outputLabel value="Branch Name" for="branchName"/>
<h:inputText id="branchName" class="form-control" value="#{branchesMB.entityEditObject.branchName}" />
</h:panelGroup>
<h:panelGroup id="branchAddressDiv" layout="block" class="form-group">
<h:outputLabel value="Branch Address" for="branchAddress"/>
<h:inputText id="branchAddress" class="form-control" value="#{branchesMB.entityEditObject.branchAddress}"/>
</h:panelGroup>
<h:panelGroup id="branchAbbreviationDiv" layout="block" class="form-group">
<h:outputLabel value="Abbreviation" for="branchAbbreviation"/>
<h:inputText id="branchAbbreviation" class="form-control" value="#{branchesMB.entityEditObject.branchAbbreviation}"/>
</h:panelGroup>
</h:panelGroup>
</div>
<div class="modal-footer">
<!--pt:data-dismiss="modal"-->
<h:commandButton id="close" value="Close" class="btn btn-default" >
<f:ajax render="branchesForm:branchesListDiv"/>
</h:commandButton>
<h:commandButton id="edit" value="Edit" action="#{branchesMB.update()}" class="btn btn-primary sye-action-btn-loading" pt:data-loading-text="Loading..." pt:autocomplete="off">
<f:ajax render=":branchesForm:branchesListDiv,:branchesForm:branchEditArea, #this" execute="branchEditArea branchesForm:branchesListDiv"/>
</h:commandButton>
<!-- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>-->
</div>
</div>
</div>
</div>
</h:panelGroup>
</h:panelGroup>
<h:panelGroup layout="block" class="box-footer">
Branches
</h:panelGroup>
</h:form>

The mistake is here:
<f:ajax render=":branchesForm:branchesListDiv,:branchesForm:branchEditArea, #this" ... />
The render and execute attributes of <f:ajax> are space separated, not comma separated.
<f:ajax render=":branchesForm:branchesListDiv :branchesForm:branchEditArea #this" ... />
Normally, this should have thrown an exception as detailed in this Q&A How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar", but since Mojarra 2.2.5 it stopped validating those attributes in order to support referencing a specific <ui:repeat> iteration round (issue-2958). Spec issue 1372 was started to address this nasty quickfix and to bring back the validation.
The comma separation is only supported in PrimeFaces <p:ajax> and this is most likely where your confusion came from. It supports both space and comma separation. It's strongly recommended to not use comma separation in <p:ajax> as it's in long term only confusing when you come back to <f:ajax>.

Related

h:commandButton in h:dataTable doesn't work after ajax render

I have a h:commandbutton in h:dataTable, and in my application have a dropdown that have ajax command to update h:dataTable. But when make update in my dataTable my commandbutton stop work.
this is my h:dataTable:
<h:dataTable value="#{viewBean.requestList}" var="o" id="request_table" class="table table-striped table-bordered table-hover" cellspacing="0" width="100%">
(...)
<h:column>
<f:facet name="header">Edit</f:facet>
<h:form>
<div style="text-align: center">
<h:panelGroup id="teste_button">
<h:commandButton title="Edit" class="btn btn-info btn-sm" action="#{navigationBean.toEdit()}" rendered="#{true}">
<span class="glyphicon glyphicon-pencil"></span>
<f:param name="selectedRequestID" value="#{o.id}" />
<f:param name="itemMenuAnterior" value="#{viewBean.itemActual}" />
</h:commandButton>
</h:panelGroup>
(...)
</div>
</h:form>
</h:column>
</h:dataTable>
this is my dropdown:
<h:form>
<h:selectOneMenu value="#{viewBean.itemActual}" id="select_filter" class="form-control">
<f:selectItems value="#{viewBean.items}" var="itematual" itemLabel="#{itematual}"/>
<f:ajax listener="#{viewBean.itemChange(event)}" render="request_table" onevent="functionName"/>
</h:selectOneMenu>
</h:form>

Passing/binding inputfield UIInput.value inside ui:repeat to bean method

I've comments that are displayed from an <ui:repeat> tag. An user can reply to to all comments with input fields that are displayed individually for each comment. However I can't manage to pass the value of the comment to the bean that deals with it. I thought about passing the UIInput value as described in the first answer [by balusC here][1]. The problem is that the content is empty because the action button is bound to every UIInput ( I believe so). I should sort of have a personal bound between each button and my UIInput. I think the code is gonna be more self-explanatory hopefully. :
<ui:repeat var="post" value="#{watchThread.listeFirstPosts}">
<h:outputText value="#{post.user.username}"/>
<div class="postContent">
<h:outputText value="#{watchThread.sanitize(post.content)}" />
</div>
<div class="replyAction">
<h:form>
<div class="inputAreaPostFast">
<p:inputTextarea id="reply2" value="#{watchThread.replyContent}" binding="#{inputReply}"/>
<div class="replyBtn">
---------- Here the third param is the issue --------------
<p:commandButton action="#{watchThread.sendReply(userNav.user, post, inputReply.value)}"/>
</div>
</div>
</h:form>
</div>
</ui:repeat>
Edit: This is the code that worked for me. (I think) I had a form that had no business of being in my ui:repeat tag. Also to bind the input see the answer/comment of balusC below. However I had to let the form tags inside and not outside as suggested.
<ui:repeat var="post" value="#{watchThread.listeFirstPosts}">
<div class="replyBlock">
<h:panelGroup id="username" style="cursor:pointer;">
<div class="profileimgForum">
<h:graphicImage styleClass="profilepicForum" value="/images/#{post.user.profilePic}" rendered="#{!empty post.user.profilePic}"></h:graphicImage>
<h:graphicImage styleClass="profilepicForum" library="images" name="profilepic1.jpg" rendered="#{empty post.user.profilePic}"></h:graphicImage>
</div>
<span class="posterTitle">
<h:outputText value="#{post.user.username}"></h:outputText> </span>
<h:outputText value=" #{watchThread.formatTimeReply(post.datePost)}"/>
</h:panelGroup>
<div class="replyContent">
<h:outputText value="#{watchThread.sanitize(post.content)}" style="pointer:cursor;"/>
</div>
<div class="replyAction">
<p:inplace id="facet" effect="none">
<f:facet name="output">
#{strings.Reply}
</f:facet>
<f:facet name="input">
<h:form>
<div class="inputAreaPostFast">
<p:inputTextarea id="reply2" cols="70" rows="7" value="#{watchThread.replyContent}" binding="#{inputReply}" maxlength="500"/>
<div class="replyBtn">
<p:commandButton update="growl" style=" margin-right: 2em;" value="#{strings.Reply}" action="#{watchThread.sendReply(userNav.user, post, inputReply)}"/>
</div>
</div>
</h:form>
</f:facet>
</p:inplace>
</div>
<ui:repeat var="areply" value="#{post.posts}">
#{areply.content} ----
</ui:repeat>
</div>
<!-- ####### Dialog username ######## -->
<p:overlayPanel for="username" id="usernamePanel" dynamic="true" showCloseIcon="true" appendToBody="1" dismissable="false">
<div class="dlgTopBlock">
<div class="dlgPicBlock">
<h:graphicImage styleClass="profilePicDialog" value="/images/#{post.user.profilePic}" rendered="#{!empty post.user.profilePic}"/>
<h:graphicImage styleClass="profilePicDialog" library="images" name="profilepic1.jpg" rendered="#{empty post.user.profilePic}"/>
</div>
<div class="dlgTopSubBlock"><div class="dlgTopTitle">
<h:graphicImage styleClass="flag" library="images/flags"
name="#{post.user.countryBean.iso2}.png"
rendered="#{! empty post.user.countryBean.iso2}"/>
<h:link value="#{post.user.username}" outcome="/user.xhtml">
<f:param name="username" value="#{post.user.username}"></f:param>
</h:link>
</div>
<div class="dlgRep">
<h:outputText value="#{post.user.reputation} #{strings.repPoints} "></h:outputText>
</div>
<div class="dlgTopStatus">
<h:outputText value="#{post.user.status}"/></div>
</div>
</div>
<div class="btnDlg">
<h:panelGroup rendered="#{userNav.isUserConnected and userNav.username != post.user.username}">
<p:commandButton value="#{usernavmsg.SendPM}" icon="ui-icon-mail-closed" onclick="PF('sendMsgDlg').show();"></p:commandButton>
<p:commandButton id="addFriend" value="#{friendBean.btnText}" action="#{friendBean.addFriend()}" update="growl addFriend" icon="#{friendBean.icon}"
rendered="#{friendBean.rendered}"/>
</h:panelGroup>
</div>
<p:dialog header="#{usernavmsg.SendingTo}: #{post.user.username}"
dynamic="true" modal="false" widgetVar="sendMsgDlg" minHeight="40">
<h:form>
<p:inputTextarea value="#{pMbean.title}" rows="1" cols="110" id="title" >
<f:passThroughAttribute name="placeholder" value="#{usernavmsg.Title}"/>
</p:inputTextarea><br/><br/>
<p:inputTextarea value="#{pMbean.message}" id="msg" rows="10" cols="110" autoResize="true">
<f:passThroughAttribute name="placeholder" value="#{usernavmsg.YourMsg}"/>
</p:inputTextarea><br/>
<p:commandButton style="float:right;" value="#{usernavmsg.Send}" action="#{pMbean.send(post.user)}"
onclick="PF('sendMsgDlg').hide();" icon="ui-icon-mail-closed" update="growl"></p:commandButton>
</h:form>
</p:dialog>
</p:overlayPanel>
<!-- ######### End of dialog user ######## -->
</ui:repeat>
The only visible mistake is the below:
<ui:repeat value="#{watchThread.listeFirstPosts}" var="post" ...>
<p:inputTextarea ... value="#{watchThread.replyContent}">
You're basically binding the value of the input field of every iteration to one and same backing bean property. So, every iteration round will override the value of the previous iteration round. This is not right. The value of the input field must be bound to the current iteration round. I.e. it should basically have been as below:
<ui:repeat value="#{watchThread.listeFirstPosts}" var="post" ...>
<p:inputTextarea ... value="#{post.replyContent}">
But, in this construct you actually don't need it. Just get rid of the value attribute altogether and rely on binding as you initially wanted to use.
Then, there's another mistake as pointed out in the comments: nesting forms. This is illegal in HTML. Don't write JSF code in such way that it produces illegal HTML. There would be another potential cause in form of a bug in Mojarra which only exposes in case you're using <f:ajax> in a nested <ui:repeat>. The solution to that would be using a fullworthy UIData component, such as <h:dataTable> or one of PrimeFaces grids.

Edit commandLink goes to Edit page but does not populate values into input fields

My edit page does not display bean values when it's called from a datalist populated by a JDBC search but works just fine if the list is not from the JDBC search.
The delete link works just fine but the edit link just returns the edit page with no populated values in the fields.
My bean is a ViewScoped bean.
The datalist display page:
<h:form rendered="#{not empty usersManagedBean.usersList}" id="form">
<div class="table-responsive">
<h:dataTable value="#{usersManagedBean.userModel}"
var="showUser"
styleClass="table table-striped table-bordered table-hover">
<h:column>
<f:facet name="header">
Username
</f:facet>
<h:outputText value="#{showUser.username}"/>
</h:column>
<h:column>
<f:facet name="header">
First Name
</f:facet>
<h:outputText value="#{showUser.firstname}"/>
</h:column>
<h:column>
<f:facet name="header">
Last Name
</f:facet>
<h:outputText value="#{showUser.lastname}"/>
</h:column>
<h:column>
<f:facet name="header">
Security Level
</f:facet>
<h:outputText value="#{showUser.groupname}"/>
</h:column>
<h:column rendered="false">
<f:facet name="header">
Security Level
</f:facet>
<h:outputText value="#{showUser.id}"/>
</h:column>
<h:column>
<h:commandLink value="Edit"
action="#{usersManagedBean.updateUser()}">
</h:commandLink>
||
<h:commandLink value="Delete"
onclick="if (!confirm('Are you sure, you want to delete #{showUser.username}?')) {
return false;
}
;
return true;
" action="#{usersManagedBean.deleteUser(showUser)}">
</h:commandLink>
</h:column>
</h:dataTable>
<h:link outcome="AddUser.xhtml" value="Add New User"/>
</div>
The edit page:
<h:form>
<div class="form-group">
<label>First Name:</label>
<h:inputText id="firstname" styleClass="form-control" value="#{usersManagedBean.user.firstname}"></h:inputText>
<label>Last Name:</label>
<h:inputText id="lastname" styleClass="form-control" value="#{usersManagedBean.user.lastname}"></h:inputText>
<label>Username:</label>
<h:inputText id="username" styleClass="form-control" value="#{usersManagedBean.user.username}"></h:inputText>
<div class="form-group">
<label>Security Level:</label>
<h:selectOneMenu id="roleSelect" value="#{usersManagedBean.user.groupname}" styleClass="form-control">
<f:selectItem itemLabel="----" itemValue="----"/>
<f:selectItem itemLabel="Administator" itemValue="admin"/>
<f:selectItem itemLabel="User" itemValue="user"/>
</h:selectOneMenu>
</div>
<label>Password:</label>
<h:inputSecret id="password" styleClass="form-control" value="#{usersManagedBean.user.password}" required="true" requiredMessage="Enter Password"/>
<h:message for="password" style="color:red"/>
<label>Confirm Password:</label>
<h:inputSecret id="password2" styleClass="form-control" required="true" requiredMessage="Re-enter Password"/>
<h:message for="password2" style="color:red" />
<o:validateEqual components="password password2" message="Passwords don't match" showMessageFor="password2"/>
</div>
<h:commandButton value="Update" type="submit" styleClass="btn btn-default" action="#{usersManagedBean.saveUser()}"></h:commandButton>
||
<h:commandButton value="Cancel" onclick="history.back(-1);return false" styleClass="btn btn-default"></h:commandButton>
</h:form>
The method that calls the edit page:
public String updateUser(){
user = userModel.getRowData();
return "EditUser.xhtml";
}
No exceptions are thrown at all.
if you use a #ViewScoped bean, jsf will create a new instance of it when you navigate from list page to edit page. you have 3 alternatives i can think of:
use #SessionScoped.
open the edit page via ajax and as a popup panel.
use #ViewScoped, add the user id to the url as a view parameter (ie. EditUser.xhtml?id=123), and load user data from db in edit page instead of list page, on page load. in this scenario, it's best to have different managed beans for list and edit pages.

Why i get previous data in dialog using primefaces?

i don't know why i get previous data when i use dialog that i call it from datatable, when i open the dialog and leave required field empty and press edit when i close the dialog and open another row i notice that the old data is appear in the fields
here's my code
<h:form id="content" prependId="false">
<c:set target="#{facilityMB}" property="facilityType" value="Recreation"/>
<h:panelGrid class="ipmagix-mainFrom" cellpadding="0" cellspacing="0" columns="1">
<h:panelGroup layout="block" class="ipmagix-breadcrumb">
<ul class="breadcrumb">
<li>Home <span class="divider">/</span></li>
<li>Services <span class="divider">/</span></li>
<li class="active">Recreation Promotion</li>
</ul>
</h:panelGroup>
<h:panelGroup layout="block" class="panel panel-primary">
<h:panelGroup layout="block" class="panel-heading">
<i class="icon-white icon-list"></i>
<i></i>
<h:outputText value="#{bundle.facilityRecreationList}"/>
</h:panelGroup>
<h:panelGroup layout="block" class="panel-body">
<p:messages id="messagesForList" showDetail="false" autoUpdate="false" closable="true"/>
<h:panelGroup layout="block" class="ipmagix-list-width" id="facilityListForm">
<ui:include src="facility-view.xhtml"/>
</h:panelGroup>
</h:panelGroup>
</h:panelGroup>
<h:panelGroup layout="block" class="panel panel-primary">
<h:panelGroup layout="block" class="panel-heading">
<i class="icon-white icon-plus"></i>
<i></i>
<h:outputText value="#{bundle.facilityRecreationAdd}" />
</h:panelGroup>
<h:panelGroup layout="block" class="panel-body">
<p:messages id="messages" showDetail="false" autoUpdate="false" closable="true"/>
<h:panelGroup layout="block" class="ipmagix-form-width form-horizontal" id="facilityAddForm">
<div class="control-group">
<h:outputLabel for="facilityName" class="control-label" value="#{bundle.name}"></h:outputLabel>
<div class="controls">
<p:inputText value="#{facilityMB.facilityName}" id="facilityName" maxlength="40" required="true" requiredMessage="#{validation.emptyName}" />
<p:watermark value="#{bundle.name}" for="facilityName"/>
</div>
</div>
<div class="control-group">
<h:outputLabel for="language" class="control-label" value="#{bundle.language}"></h:outputLabel>
<div class="controls">
<p:selectOneMenu id="language" value="#{facilityMB.languageId}">
<f:selectItems value="#{facilityMB.languageList}" var="lang" itemValue="#{lang.languageID}" itemLabel="#{lang.languageName}" />
</p:selectOneMenu>
</div>
</div>
<div class="control-group">
<h:outputLabel for="facilityDesc" class="control-label" value="#{bundle.description}"></h:outputLabel>
<div class="controls">
<p:inputTextarea value="#{facilityMB.facilityDesc}" id="facilityDesc" maxlength="100" style="width: 80%" autoResize="false" rows="3" required="true" requiredMessage="#{validation.emptyDescription}" />
<p:watermark value="#{bundle.description}" for="facilityDesc"/>
</div>
</div>
<h:panelGroup layout="block" id="uploader" class="control-group">
<h:outputLabel class="control-label" value="#{bundle.imageURL}"></h:outputLabel>
<div class="controls">
<p:fileUpload fileUploadListener="#{facilityMB.handleFileUpload}" mode="advanced"
update="uploader, messages" auto="true" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
</div>
</h:panelGroup>
<div class="control-group well well-small">
<p:commandButton id="saveFacility" value="#{bundle.save}" styleClass="btn btn-mini btn-primary" icon="ui-icon-plus" action="#{facilityMB.saveFacility()}"
oncomplete="filter();" update ="facilityAddForm, facilityListForm, messages">
</p:commandButton>
</div>
</h:panelGroup>
</h:panelGroup>
</h:panelGroup>
</h:panelGrid>
<h:panelGroup layout="block" id="uiBlock">
<p:blockUI block="facilityListForm" trigger="saveFacility" >
LOADING<br />
<p:graphicImage value="#{resource['images:ajax-loader.gif']}"/>
</p:blockUI>
<p:blockUI block="facilityAddForm" trigger="saveFacility" >
LOADING<br />
<p:graphicImage value="#{resource['images:ajax-loader.gif']}"/>
</p:blockUI>
</h:panelGroup>
</h:form>
<h:form id="dialogForm" prependId="false">
<p:dialog id="dialog" modal="true" width="80%" resizable="false" header="Edit Special Promotion" widgetVar="dlg" dynamic="true">
<p:ajax event="close" update=":content:facilityListForm" />
<h:panelGroup layout="block" id="dialogContent">
<ui:include src="facility-edit.xhtml"/>
</h:panelGroup>
</p:dialog>
</h:form>
</ui:define>
and this is view page is be included
<p:dataTable widgetVar="tableVar" id="facilityDataTable" scrollWidth="100%" value="#{facilityMB.facilityList}" var="facility" paginator="true" editable="true" emptyMessage="#{bundle.emptyData}" rows="5" filteredValue="#{facilityMB.facilityFilterList}" >
<p:column headerText="Image" width="100">
<p:lightBox height="100">
<h:outputLink value="#">
<img src="#{facility.imageURL}" width="100" height="100"/>
</h:outputLink>
<f:facet name="inline">
<img src="#{facility.imageURL}" width="500" height="500"/>
</f:facet>
</p:lightBox>
</p:column>
<p:column headerText="#{bundle.name}" sortBy="#{facility.facilityName}" filterBy="#{facility.facilityName}" rendered="#{facilityMB.facilityType != 'Special Promotion'}">
<p:cellEditor >
<f:facet name="output">
<h:outputText id="ink" value="#{facility.facilityName}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{facility.facilityName}" maxlength="40" required="true" requiredMessage="The name is not valid"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column width="5%" headerText="#{bundle.language}" sortBy="#{facility.languageID.languageName}" filterBy="#{facility.languageID.languageName}">
<h:outputText value="#{facility.languageID.languageName}"/>
</p:column>
<p:column headerText="#{bundle.description}" sortBy="#{facility.facilityDescription}" filterBy="#{facility.facilityDescription}" rendered="#{facilityMB.facilityType != 'Special Promotion'}">
<p:cellEditor >
<f:facet name="output">
<h:outputText value="#{facility.facilityDescription}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{facility.facilityDescription}" maxlength="100" required="true" requiredMessage="The description is not valid"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column width="2%">
<p:commandLink styleClass="ui-icon ui-icon-trash" immediate="true"
oncomplete="filter()" action="#{facilityMB.deleteFacility(facility)}" update=":content:facilityDataTable, :content:messagesForList">
</p:commandLink>
</p:column>
<p:column width="4%">
<p:commandButton id="basic" value="Edit" immediate="true" action="#{facilityMB.prepareEdit(facility)}" oncomplete="dlg.show();filter();" update=":dialogForm:dialogContent" >
<f:setPropertyActionListener target="#{facilityMB.selectedFacility}" value="#{facility}"/>
</p:commandButton>
</p:column>
</p:dataTable>
Do not keep p:dialog inside h:form, instead keep h:form inside p:dialog.
Then you can update the h:form or any h:panelGroup inside p:dialog.
If you want to do it from Javascript use loadContents() function on p:dialog's widgetWar object.
For Example:
<h:form id="form1">
<p:commandButton update=":form2" oncomplete="myDialogWidget.loadContents()"/>
</h:form>
<p:dialog widgetWar="myDialogWidget" appendToBody="true">
<h:form id="form2">
....
</h:form>
</p:dialog>
Use update=":dialogForm" on edit command button. So whenever you open dialogbox, previous data will get refreshed.

Update component on template.xhtml from test.xhtml

I have a menutab on my template that i am using on every page. I would like to update a component from the template from another paged which is based on the template.
Its working like just any other emailpage, as soon as i read an email, it should update the number of the unread emails. The number is shown in the menutab in the template.xhtml and the emails are on my test.xhtml. As soon as I read an email it should update the number of the unread emails in the menutab in template.xhtml.
this is my template.xhtml
<ui:define name="navi">
<h:form id="navForm">
<div id="MMeineVersicherungen" class="hauptmenu">
<h:commandLink action="#{navigationController.switchView('1')}">#{messages['menu.1']}</h:commandLink>
</div>
<div id="MPolizzen" class="menuitem">
<h:commandLink action="#{navigationController.switchView('1.1')}"
styleClass="#{navigationController.isAktPageId('1.1') or navigationController.isAktPageId('1') ? 'activelink' : ''}">- #{messages['menu.1.1']}</h:commandLink>
</div>
<div id="MSchaeden" class="menuitem">
<h:commandLink action="#{navigationController.switchView('1.2')}"
styleClass="#{navigationController.isAktPageId('1.2') ? 'activelink' : ''}">- #{messages['menu.1.2']}</h:commandLink>
</div>
<div id="MTopKunden" class="menuitem">
<h:commandLink action="#{navigationController.switchView('1.3')}"
styleClass="#{navigationController.isAktPageId('1.3') ? 'activelink' : ''}">- #{messages['menu.1.3']}</h:commandLink>
</div>
<div id="MMeineDaten" class="hauptmenu">
<h:commandLink action="#{navigationController.switchView('2')}">#{messages['menu.2']}</h:commandLink>
</div>
<div id="MKundendaten" class="menuitem">
<h:commandLink action="#{navigationController.switchView('2.1')}"
styleClass="#{navigationController.isAktPageId('2.1') or navigationController.isAktPageId('2') ? 'activelink' : ''}">- #{messages['menu.2.1']}</h:commandLink>
</div>
<div id="MBenutzer" class="menuitem">
<h:commandLink action="#{navigationController.switchView('2.2')}"
styleClass="#{navigationController.isAktPageId('2.2') ? 'activelink' : ''}">- #{messages['menu.2.2']} </h:commandLink>
</div>
<div id="MPostfach" class="hauptmenu">
<h:commandLink action="#{navigationController.switchView('3')}"
styleClass="#{navigationController.isAktPageId('3') ? 'activelink' : ''}">(#{post.getAnzahlNeueNachrichten()}) #{messages['menu.3']} </h:commandLink>
</div>
<div id="MKommunikationsvereinb" class="hauptmenu">
<h:commandLink action="#{navigationController.switchView('4')}"
styleClass="#{navigationController.isAktPageId('4') ? 'activelink' : ''}">#{messages['menu.4']}</h:commandLink>
</div>
<div id="MAbmelden" class="hauptmenu" style="margin-top: 20px;">
<h:commandLink action="#{loginController.logout}"
value="#{messages['menu.5']}" />
</div>
</h:form>
</ui:define>
this is test.xhtml
<ui:define name="main">
<h:form id="postform">
<p:dialog id="msgdlg" dynamic="true" modal="true" widgetVar="msgdlg"
width="600" height="500">
<f:facet name="header">#{post.aktNachricht.subject}</f:facet>
<p:ajax event="close" listener="#{post.closeDlg}" />
<p:hotkey bind="esc" handler="msgdlg.hide(); " />
<ui:include src="#{post.view}" />
</p:dialog>
<p:tabView id="posttabview" activeIndex="0" cache="true">
<p:tab id="empftab" title="#{messages['post.empfangen']}"
titleStyleClass="thementab">
<p:dataTable value="#{post.empfangenList}" var="msg">
<p:column styleClass="coldatum">
<p:commandLink action="#{post.showNachricht(msg)}"
oncomplete="msgdlg.show();" update=":postform">
<h:outputText value="#{msg.datum}"
styleClass="#{msg.gelesen ? '' : 'unread'}">
<f:convertDateTime pattern="dd.MM.yyyy"
timeZone="Europe/Berlin" />
</h:outputText>
</p:commandLink>
</p:column>
<p:column>
<h:outputText value="#{msg.subject}"
styleClass="#{msg.gelesen ? '' : 'unread'}" />
</p:column>
</p:dataTable>
</p:tab>
<p:tab id="sendtab" title="#{messages['post.gesendet']}"
titleStyleClass="thementab">
</p:tab>
</p:tabView>
<br />
<p:commandButton value="#{messages['post.neu']}" action="#{post.neu}"
update="msgdlg" oncomplete="msgdlg.show();" />
</h:form>
</ui:define>

Resources