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());
}
Related
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
I'm nesting a datable in tabview. On the first page its all working correctly and i can edit the table, but after i switch the tabs, the datatable isnt editable anymore.
Is there something i'm doing wrong?
Using Primefaces 5.3
<h:form id="form">
<p:tabView id="tabs" value="#{studentsTableView.exams}" activeIndex="#{studentsTableView.activTab}" dynamic="true" var="exam" binding="#{tabView}" cache="false" >
<p:ajax event="tabChange" update="form:tabs" />
<p:tab id="tab" title="#{exam.name}">
<p:dataTable id="students" rowIndexVar="rowIndex" var="student" editable="true" widgetVar="gradetable" editMode="cell" tableStyle="width:auto" styleClass="myTable" value="#{studentsTableView.students}">
<p:ajax event="cellEdit" update="students" />
<p:column headerText="Nr">
<h:outputText value="#{rowIndex+1}" />
</p:column>
<p:column headerText="Vorname">
<h:outputText value="#{student.vorname}" />
</p:column>
<p:column headerText="Nachname">
<h:outputText value="#{student.nachname}" />
</p:column>
<p:column headerText="Matrikelnummer">
<h:outputText value="#{student.matrikelnummer}" />
</p:column>
<p:columns value="#{exam.allExams}" var="subexam" columnIndexVar="colIndex">
<f:facet name="header">
<h:outputText value="#{subexam.examName}" />
</f:facet>
<p:cellEditor>
<f:facet name="output"><h:outputText id="modeloutput" value="#{studentsTableView.getGrade(subexam, student)}" /></f:facet>
<f:facet name="input"><p:inputText id="modelInput" value="#{studentsTableView.currentGrade}" valueChangeListener="#{studentsTableView.insertGrade(subexam, student)}" style="width:90%">
<p:ajax event="change" update="modelInput" />
<p:ajax event="change" update="modeloutput" />
<p:ajax event="change" update="modeloutput" />
<p:ajax event="change" update=":form:tabs:0:students" />
</p:inputText></f:facet>
</p:cellEditor>
</p:columns>
<p:column id="endgrades" headerText="Endnote">
<h:outputText id="endgrade" value="#{studentsTableView.getEndGrade(exam, student)}" />
</p:column>
<p:column headerText="Formel">
<p:selectBooleanButton id="value1" value="true" onLabel="Yes" offLabel="No" style="width:60px" />
</p:column>
<p:column headerText="Kommentar">
<p:commandButton id="public" icon="ui-icon-comment" type="button" >
<p:ajax event="click" listener="#{studentsTableView.setPublicCommentInfos(exam, student)}" update="publicarea" />
</p:commandButton>
<p:overlayPanel id="imagePanel" for="public" hideEffect="fade">
<h:inputTextarea id="publicarea" value="#{studentsTableView.publicComment}" >
<p:ajax event="change" update="publicarea" />
</h:inputTextarea>
</p:overlayPanel>
<p:commandButton id="private" icon="ui-icon-locked" type="button" >
<p:ajax event="click" listener="#{studentsTableView.setPrivateCommentInfos(exam, student)}" update="privatearea" />
</p:commandButton>
<p:overlayPanel id="privatepanel" for="private" hideEffect="fade">
<h:inputTextarea id="privatearea" value="#{studentsTableView.privateComment}" >
<p:ajax event="change" update="privatearea" />
</h:inputTextarea>
</p:overlayPanel>
</p:column>
</p:dataTable>
</p:tab>
</p:tabView>
</h:form>
Your problem could be because you're still referencing the datatable id from the first tab, even though you switched to another. You could try to create a different id for each datatable from each tab and then working with those ids and updating them.
I have a <h:dataTable> adds contents of an input text to a list in a nested <h:dataTable>. A hidden command button is linked to the input text
Problem is only the first input text's action method work, hence only list attached to the first thread of the parent message is updated not the consecutive once.
<p:tabView id="tabView">
<p:tab id="tab1" title="Conversation">
<h:form id="pol">
<p:dataTable var="message"
value="#{channelBean.getBean('channel').messageList}"
id="messageListTable">
<p:column>
<f:facet name="header">Photo</f:facet>
<h:outputText value="Photo" />
</p:column>
<p:column>
<f:facet name="header">Message</f:facet>
<p:panelGrid columns="1">
<p:panelGrid columns="3">
<h:outputText value="#{message.sender}" />
<h:outputText rendered="#{message.channel!=null}"
value="#{message.channel.name}" />
<h:outputText value="#{message.message}" escape="false" />
</p:panelGrid>
<p:panelGrid columns="8">
<h:outputText value="#{message.postedString}" />
<h:form>
<p:commandLink id="likeLink" value="UnLike"
rendered="#{message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.like(message)}" />
</p:commandLink>
<p:commandLink id="unLikeLink" value="Like"
rendered="#{!message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.unLike(message)}" />
</p:commandLink>
<h:outputText value="." />
<h:outputText value="Reply" />
<h:outputText value="." />
<h:outputText value="Share" />
<h:outputText value="." />
<p:commandLink id="moreLink" value="More" />
<p:menu overlay="true" trigger="moreLink" my="left top"
at="left bottom">
<p:menuitem value="Save" icon="ui-icon-disk" />
<p:menuitem value="Update" icon="ui-icon-arrowrefresh-1-w" />
</p:menu>
</h:form>
</p:panelGrid>
</p:panelGrid>
</p:column>
</p:dataTable>
</h:form>
</p:tab>
<p:tab id="tab2" title="Info">
<h:form id="channelViewForm">
<l:inputTextarea
cid="com_fourforbusiness_esm_shared_domain_ffbesm_Channel_description"
label="#{msg.description}:"
value="#{channelBean.getBean('channel').description}" />
<p:commandLink value="#{msg.save}"
update=":sideBarForm:subscribedChannels,#parent">
<f:actionListener
binding="#{channelBean.saveChannel('channel')}" />
</p:commandLink>
</h:form>
</p:tab>
<p:tab id="tab3" title="File"></p:tab>
<p:tab id="tab4" title="Notes"></p:tab>
</p:tabView>
</p:panel>
<p:panel id="inbox" visible="#{mainViewBean.currentView=='IN_BOX'}"
autoUpdate="true">
<h:form id="pol">
<p:dataTable var="message"
value="#{channelBean.subscribedChannelsMessages}"
id="messageListTable"
>
<p:column>
<f:facet name="header">Photo</f:facet>
<h:outputText value="Photo" />
</p:column>
<p:column>
<f:facet name="header">Message</f:facet>
<p:panelGrid columns="1">
<p:panelGrid columns="3">
<h:outputText value="#{message.sender}" />
<h:outputText rendered="#{message.channel!=null}"
value="#{message.channel.name}" />
<h:outputText value="#{message.message}" escape="false" />
</p:panelGrid>
<p:panelGrid columns="8" id="panelx">
<h:outputText value="#{message.postedString}" />
<h:form>
<p:commandLink id="likeLink" value="UnLike"
rendered="#{message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.like(message)}" />
</p:commandLink>
<p:commandLink id="unLikeLink" value="Like"
rendered="#{!message.liked}" update="#parent" ajax="false">
<f:actionListener binding="#{channelBean.unLike(message)}" />
</p:commandLink>
<h:outputText value="." />
<p:commandLink id="replyLink" value="Reply" action="#{channelBean.enabletextbox}" process="#this" ajax="true" update=":pol">
</p:commandLink>
<h:outputText value="." />
<h:outputText value="Share" />
<h:outputText value="." />
<p:commandLink id="moreLink" value="More" />
<p:menu overlay="true" trigger="moreLink" my="left top"
at="left bottom">
<p:menuitem value="Save" icon="ui-icon-disk" />
<p:menuitem value="Update" icon="ui-icon-arrowrefresh-1-w" />
</p:menu>
<BR></BR>
<p:inputText value="#{channelBean.repli}" rendered="#{channelBean.replyClicked}" id="replyTxt" ></p:inputText>
<p:commandButton value="repSave" ajax="true" actionListener="#{channelBean.addMessage(message)}" rendered="#{channelBean.replyClicked}" update=":pol" style="visibility: hidden;" oncomplete="alert('#{message.message}');"> </p:commandButton>
<p:dataTable var="rep" id="replyListTable" value="#{message.replyList}">
<p:column headerText="Replies">
<h:outputText value="#{rep.reply}" />
</p:column>
</p:dataTable>
</h:form>
</p:panelGrid>
</p:panelGrid>
</p:column>
</p:dataTable>
</h:form>
</p:panel>
Backing bean:
public void addMessage (Message msg)
{
List<Message> subList=this.getSubscribedChannelsMessages();
for(Message mess:subList)
{
if(mess.getMessage().equalsIgnoreCase(msg.getMessage()))
{
msg.getReplyList().add(new Reply (repli));
repli = "";
replyClicked = false;
}
}
}
public void enabletextbox()
{
if (replyClicked==false)
replyClicked =true;
else
replyClicked = false;
}
I don't understand why the <p:commandButton> of the nested <h:dataTable> doesn't invoke its actionListener. How is this caused and how can I solve it?
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>
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>