Primefaces cant fill inputText in dialog after click contextmenu - jsf

I'm using Primefaces Datatable-ContextMenu and Dialog to update a row (When after click to contextmenu it opens a dialog which contains will update object's fields in <p:inputext />).
I have tried dynamic true, initilazing object on constructor because when page is rendered selectedObject will be null in dialog and when I tried to use it gives null pointer exception so that i need other advices.
Here is ContextMenu:
<p:contextMenu for="functions" id="functionContextMenu">
<p:menuitem value="Guncelle" icon="ui-icon-" update="updateDialog" oncomplete="updateDialog.show()"/>
And my dialog is here:
<p:dialog header="Guncelle" widgetVar="updateDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold" id="updateDialog" dynamic="true">
<h:panelGroup id="display">
<h:outputText value="#{functionControllerBean.selectedFunction.functionName}" />
<h:inputText id="firstName" value="{functionControllerBean.tempSelectedFunction1.functionName}" />
</h:panelGroup>
</p:dialog>
If I dont use <p:inputText /> its ok and show what i put <h:outputText /> but when i put p:inputext inside of dialog;it doesnt show output text value and shows <p:inputText /> empty even its not.
I had used beanname.objectname.field before inside of <p:inputText /> or <h:inputText /> but there was no problem but now it's not working.
And here is my ManagedBean :
#ManagedBean
#RequestScoped
public class FunctionControllerBean implements Serializable {
private EfaFunctions willAddFunction;
private EfaFunctions selectedFunction = new EfaFunctions();
Thanks in advance
UPDATE Here is page
<h:form id="form">
<p:contextMenu for="functions" id="functionContextMenu">
<p:menuitem value="Guncelle" icon="ui-icon-" update="updateDialog" oncomplete="updateDialog.show()"/>
<p:menuitem value="Sil" update="#form" icon="ui-icon-close" actionListener="#{functionControllerBean.deleteFunction}"/>
</p:contextMenu>
<p:dataTable resizableColumns="true" id="functions" var="function" value="#{functionControllerBean.functions}" rowKey="#{function.functionId}"
selection="#{functionControllerBean.selectedFunction}" selectionMode="single">
<p:column headerText="Id">
#{function.functionId}
</p:column>
<p:column headerText="Key ">
#{function.functionKey}
</p:column>
<p:column headerText="Isim" >
#{function.functionName}
</p:column>
<p:column headerText="Tip" >
#{function.functionType}
</p:column>
<p:column headerText="Url" >
#{function.uri}
</p:column>
<p:column headerText="Olusturulma Tarihi" >
#{function.creationDate}
</p:column>
<p:column headerText="Guncelleme Tarihi" >
#{function.lastUpdateDate}
</p:column>
<p:column headerText="Olusturan Kisi" >
#{function.createdBy}
</p:column>
<p:column headerText="Guncelleyen Kisi" >
#{function.createdBy}
</p:column>
</p:dataTable>
<p:dialog header="Islem Sonucu" widgetVar="actionResult" resizable="false"
width="200" showEffect="clip" hideEffect="fold" id="actionResult"
visible="#{functionControllerBean.actionResult!=null}">
<h:outputText value="#{functionControllerBean.actionResult}"/>
</p:dialog>
<p:dialog header="Guncelle" widgetVar="updateDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold" id="updateDialog" >
<h:panelGroup id="display">
<h:outputText value="#{functionControllerBean.selectedFunction.functionName}" />
<p:inputText value="#{functionControllerBean.selectedFunction.functionName}"/>
</h:panelGroup>
</p:dialog>
</h:form>

Related

Refresh a table inside a pdialog from other pdialog edit panel JSF, primefaces showcase 6.0

JSF, Primefaces Showcase 6.0
Please could you help me? I'm trying to refresh a table which is in a p:dialog, from other p:dialog from here
<p:dialog header="Editar Estado Ficha" widgetVar="dialogo3"
id="dialogo3" modal="true" height="275" width="400">
<h:form id="form9">
<p:panelGrid columns="2">
<h:outputText value="Fecha:" />
<h:outputText value="#{controllerFichaEstado.fecha}" />
<h:outputText value="Estado:" />
<h:outputText value="#{controllerFichaEstado.id_estadoS}" />
<h:outputText value="Observacion:" />
<p:inputTextarea value="#{controllerFichaEstado.observacion}"
cols="10" style="width:100%" required="true"
requiredMessage="Especifique la observacion" />
<p:commandButton value="Actualizar" update=":form7:tabla2"
icon="ui-icon-pencil"
actionListener="#{controllerFichaEstado.actionListenerActualizar()}"></p:commandButton>
</p:panelGrid>
</h:form>
</p:dialog>
to this datatable
<p:dialog header="Asignar estado de ficha" widgetVar="fe"
id="estadoficha" modal="true" height="300" width="75%">
<h:form id="form7">
<p:panel header="LISTA DE ESTADO DE FICHA">
<p:dataTable value="#{controllerFichaEstado.listadoxficha}" var="c"
id="tabla2">
<p:column headerText="FICHA">
<h:outputText value="#{c.ficha.idFicha}" />
</p:column>
<p:column headerText="NOMBRE">
<h:outputText value="#{c.ficha.estudiante.nombreE}" />
</p:column>
<p:column headerText="APELLIDO">
<h:outputText value="#{c.ficha.estudiante.apellidoE}" />
</p:column>
<p:column headerText="ESTADO FICHA">
<h:outputText value="#{c.estado.descripcion}" />
</p:column>
<p:column headerText="FECHA">
<h:outputText value="#{c.fechaEstado}" />
</p:column>
<p:column headerText="OBSERVACION" style="width:300px">
<h:outputText value="#{c.observacionEstado}" />
</p:column>
<p:column style="width:80px">
<p:commandButton icon="ui-icon-pencil" update="form9"
onclick="PF('dialogo3').show();"
actionListener="#{controllerFichaEstado.actionListenerCargar(c)}"></p:commandButton>
<p:commandButton icon="ui-icon-trash" update=":form7:tabla2"
actionListener="#{controllerFichaEstado.actionListenerEliminar(c.idFichaestado,c)}"></p:commandButton>
</p:column>
</p:dataTable>
</p:panel>
</h:form>
<p:commandButton icon="ui-icon-pencil" value="Asignar"
actionListener="#{controllerFichaEstado.limpiar()}"
onclick="PF('ingresoeficha').show();"></p:commandButton>
</p:dialog>
I supposed with this code it going to work but it doesn't
update=":form7:tabla2", actually it works with a full refresh page (F5), I'd like to work without an all refreshing page

How can I use datatable selection in dialog widget in PrimeFaces?

I am trying to use datatable selection in dialog widget. But I cannot get selected value in my bean. Datatable selection is working, if I delete dialog widget tag. I am using PrimeFaces 4.0. How can I fix this?
passengerform.xhtml
<p:hotkey bind="esc" handler="dialogWidget.hide();" />
<p:dialog id="dialog" widgetVar="dialogWidget"
header="Coupon List" modal="true" width="400" showEffect="fade"
hideEffect="fade" appendTo="#(body)">
<h:form id="formDialog">
<h:outputLabel value="Lütfen E-ticket Kuponunu Seçiniz." />
<p:dataTable id="singleDT" var="coupon"
value="#{passengerFormService.couponList}"
rowKey="#{coupon.id}" rowIndexVar="rowIndex"
selection="#{passengerFormService.selectedCoupon}"
selectionMode="single">
<p:ajax event="rowSelect"
listener="#{passengerFormService.selectCoupon}"
update=":tab1:tab1_1:eticketform:formDialog">
<f:setPropertyActionListener value="#{coupon}"
target="#{passengerFormService.coupon}" />
</p:ajax>
<f:facet name="header"></f:facet>
<h:inputHidden name="hidden1"
value="#{passengerFormService.passengerForm.id}" />
<p:column style="width:20px" width="20">
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="#{rowIndex+1}" />
</p:column>
<p:column headerText="Id">
<h:outputText value="#{coupon.id}" />
</p:column>
<p:column headerText="Departure Location">
<h:outputText value="#{coupon.departureLocation}" />
</p:column>
<f:facet name="footer"></f:facet>
</p:dataTable>
<p:separator />
<h:panelGrid columns="2" cellspacing="5"
columnClasses="alignLeft,alignRight" style="width:100%">
<p:commandButton id="selectButton1" update=""
icon="ui-icon-close" value="İptal"
oncomplete="PF('dialogWidget').hide()" />
<p:commandButton id="cancelSelectedButton1"
update=":tab1:tab1_1:passengerInsertform"
icon="ui-icon-check"
value="Onayla" oncomplete="PF('dialogWidget').hide()" />
</h:panelGrid>
</h:form>
</p:dialog>
PassengerFormService.java
public void selectCoupon(SelectEvent event) {
Log.getLogger().debug("New2 coupon selected...");
Log.getLogger().debug("selected: " +getSelectedCoupon());
}

update primefaces or jsf view after ajax call on submit button

I am trying to update a primefaces form (wizard-first step) after an ajax command button request with no success. The command button that makes the actual ajax call is on a dialog. I would like after submitting the request to force my view to refresh.
The command button deletes a record from a datatable. It works fine, record is deleted but when dialog is hidden the datatable keeps displaying the deleted record. I would like to force it somehow to refresh. Any ideas? Could I do it from my backing bean reviewManagerBean.deleteProtocol() method?
Here is the code (my BackBean is viewScoped):
<h:form id="reviewManagerForm">
...
<pe:masterDetail id="masterDetail" level="#{reviewManagerBean.currentLevel}" showBreadcrumb="false" selectLevelListener="#{reviewManagerBean.levelListener}" >
<f:facet name="header" >
<h:panelGroup layout="block" style="margin-top: 10px;" >
<h:panelGroup styleClass="levelTitle ui-state-default ui-corner-all wizard-breadcrumbs#{reviewManagerBean.currentLevel eq 1 ? 'ui-state-hover' : ''}">
<h:outputText value="1: Protocol picker"/>
</h:panelGroup>
...
<p:messages id="mainMessagesPanel" showDetail="true" closable="true" />
</h:panelGroup>
</f:facet>
<pe:masterDetailLevel level="1">
<p:panel id="panel1" header="List of available protocols">
<p:dataTable id="protocolsDataTable" var="cRProtocol" rowKey="#{cRProtocol.revProtId}" value="#{reviewManagerBean.cRReviewProtocolList}"
widgetVar="protocolsTable"
...
selection="#{reviewManagerBean.selectedReviewProtocol}"
selectionMode="single" >
...
<p:ajax event="rowSelect" listener="#{reviewManagerBean.setSelectedRow}" />
<p:ajax event="rowUnselect" listener="#{reviewManagerBean.unsetSelectedRow}"/>
...
<p:column sortBy="#{cRProtocol.revProtTitle}" headerText="Title" style="width:200px;text-align:center;">
<h:outputText value="#{cRProtocol.revProtTitle}" />
</p:column>
...
<p:column>
<p:commandButton value="Delete" onclick="dlg5.show()"
update=":reviewManagerForm:deleteSingleProtocol"
disabled="#{reviewManagerBean.checkifProtocolIsOpen(cRProtocol)}"
ajax="true" process=":reviewManagerForm:deleteSingleProtocol" />
</p:column>
</p:dataTable>
</p:panel>
...
<p:dialog id="dialog-deleteprotocol" header="Delete Image Type" widgetVar="dlg5" dynamic="true" modal="true" resizable="false">
<p:panelGrid id="deleteSingleProtocol">
<p:row>
<p:column>
<h:outputText value="Id:" style="font-weight:bold; padding-right:10px" />
</p:column>
<p:column>
<h:outputText value="#{reviewManagerBean.selectedReviewProtocol.revProtId}" />
</p:column>
</p:row>
...
<p:column>
<p:commandButton id='protocolDelete'
value='Delete'
action='#{reviewManagerBean.deleteProtocol()}'
ajax="true"
onclick="dlg5.hide()" icon="ui-icon-disk"
update=":reviewManagerForm:protocolsDataTable"
process=":reviewManagerForm:deleteSingleProtocol" />
</p:column>
</p:row>
</p:panelGrid>
</p:dialog>
Your datatable should be re-rendered properly, you would have gotten an exception otherwise (something like component with id :reviewManagerForm:protocolsDataTable could not be found).
This means that #{reviewManagerBean.cRReviewProtocolList} will get called again. You need to remove the item from that list. This is appropriately done from #{reviewManagerBean.deleteProtocol}.
When #{reviewManagerBean.cRReviewProtocolList} is called after the removal, your datatable will get updated.

Primefaces 3.5 DataTable Single Selection does not work with ContextMenu

I tried to make a <p:dataTable> with <p:contextMenu> using primefaces 3.5 on Mojarra 2.2.1.
The ContextMenu Code :
<p:contextMenu for="actionnairesDT">
<p:menuitem value="View" update="displayActionnaires" icon="ui-icon-search" oncomplete="actDialog.show()"/>
<p:menuitem value="Delete" update="actionnairesDT" icon="ui-icon-close" />
</p:contextMenu>
the problem is that the dialog box is displayed empty.
I tried to show my object in the setter setSelecedActionnaire(), it displays nothing
not even null.
public void setSelectedActionnaire(Actionnaires selectedActionnaire) {
System.out.println(selectedActionnaire);
this.selectedActionnaire = selectedActionnaire;
}
<p:dataTable> and <p:dialog> code is below. thank you in advance for your help !
<p:dataTable id="actionnairesDT" paginatorPosition="bottom"
pageLinks="10" paginator="true" rows="20" value="#{actionnairesBean.actionnairesList()}" var="actionnaires"
rowKey="#{actionnaires.nomAct}" selection="#{actionnairesBean.selectedActionnaire}" selectionMode="single"
>
<p:ajax event="rowSelect" update="actionnairesDT" oncomplete="actDialog.show()" />
<p:column sortBy="#{actionnaires.actionnairesPK.codeAct}" headerText="N°">
#{actionnaires.actionnairesPK.codeAct}
</p:column>
<p:column headerText="Nom" sortBy="#{actionnaires.nomAct}">
#{actionnaires.nomAct}
</p:column>
<p:column>
#{actionnaires.quatiteAct}
</p:column>
<p:column headerText="Sicav">
#{actionnaires.actionnairesPK.codeSicav}
</p:column>
</p:dataTable>
<p:dialog header="Détail Actionnaire" widgetVar="actDialog" resizable="false"
showEffect="clip" hideEffect="fold" id="actDialog" closable="true" modal="true">
<h:panelGrid id="displayActionnaires" columns="2" cellpadding="4">
<h:outputText value="Nom Actionnaire"/>
<h:outputText value="#{actionnairesBean.selectedActionnaire.nomAct}"/>
<h:outputText value="Quantité"/>
<h:outputText value="#{actionnairesBean.selectedActionnaire.quatiteAct}"/>
<h:outputText value="Sicav"/>
<h:outputText value="#{actionnairesBean.selectedActionnaire.sicavs.libelleSicav}"/>
</h:panelGrid>
</p:dialog>
In the end, I found the solution
I add <p:ajax> to the <p:dataTable>:
<p:ajax event="contextMenu"/>

update inputtext via dialog

Please help me to find a example to update p:inputtext with data stored in a bean which is set(solved already) by selecting a row of a datatable of a p:dialog. I have succeeded updating outputtext in the same manner.
I am using (learning) netbeans 7.2 primefaces 3.2, glassfish 3.1
thansk for all your help
rs_ncs
Look at primefaces showcase and the user guide, you'll find everything you need; in detail search for rowSelect event for the datatable component. Good luck =)
If you would like to update a component on select of a row from a datatable, then you can use the update attribute of a <p:ajax> which is listening on rowselect event. Something like this:
<p:ajax event="rowSelect" update=":xx:xx" />
As Suggested by BalusC the code <p:ajax event="rowSelect" update=":xx:xx" /> should work....
Here is an example of updating both inputtext and outputtext .
<h:form>
<p:dataTable id="usertable" var="user" value="#{userManageBean.userList}"
rowKey="#{user.U_ID}" selection="#{userManageBean.selectedUser}"
selectionMode="single" paginator="true" rows="18" >
<p:ajax event="rowSelect" update=":useredit:edituser" />
<p:ajax event="rowSelect" update=":viewuser:displayuser" />
<p:column headerText="User Name">
<h:outputText value="#{user.username}" />
</p:column>
<p:column headerText="FName">
<h:outputText value="#{user.firstname}" />
</p:column>
<p:column headerText="LName">
<h:outputText value="#{user.lastname}" />
</p:column>
</p:dataTable>
</h:form>
<p:dialog id="userview" header="View User" widgetVar="dlg2" >
<h:form id="viewuser">
<h:panelGrid id="displayuser" columns="2" cellpadding="4">
<h:outputText value="User Name:" />
<h:outputText value="#{userManageBean.selectedUser.username}" />
<h:outputText value="First Name" />
<h:outputText value="#{userManageBean.selectedUser.firstname}" />
<h:outputText value="Last Name:" />
<h:outputText value="#{userManageBean.selectedUser.lastname}" />
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="user_edit" header="Edit User" widgetVar="dlgedit" >
<h:form id="useredit">
<h:panelGrid id="edituser" columns="2" cellpadding="4">
<h:outputText value="First Name" />
<h:inputText value="#{userManageBean.selectedUser.firstname}" />
<h:outputText value="Last Name" />
<h:inputText value="#{userManageBean.selectedUser.lastname}" />
<p:commandButton id="updateUser" value="Add" action="#{someaction}"
ajax="false" />
</h:panelGrid>
</h:form>
</p:dialog>

Resources