After much hair-pulling, I am finally able to open a full html page as a dialog box. I'm doing this with a commandLink as the button needs to be a clickable image.
Unfortunately it seems that commandLink does not handle the "returnDialog" event.
What would be a convenient way do get hold of the data from the dialog in this case ?
<h:form>
<h:commandLink id="pdf" actionListener="#{testBean.viewSelector}">
<h:graphicImage library="images" name="icon_pdf.png" />
<p:ajax event="dialogReturn" etc.. /><!-- This does not work -->
</h:commandLink>
<p:commandButton value="View" icon="ui-icon-extlink" actionListener="#{testBean.viewSelector}">
<p:ajax event="dialogReturn" listener="#{testBean.onPageSelectionSubmitted}" /><!-- This one does but I don't want a button -->
</p:commandButton>
</h:form>
EDIT version + implementation info :
primefaces 5.3
JSF 2.2, mojarra
My requierement is to upload some data and generate different reports for download with one click. In the example below I show appropriate button witch has a parameter that is sent to the download bean to select the correct version of the report.
But the f:param is only set the first time a p:commandButton is executed and then stays the same also for other buttons. Why is that and how can I solve this issue?
<h:form id="mainForm" enctype="multipart/form-data">
<p:fileUpload ...../>
....
....
<p:selectBooleanCheckbox id="opt1"
<p:ajax event="change" update="hiddingPanel"/>
</p:selectBooleanCheckbox>
<p:selectBooleanCheckbox id="opt2"
<p:ajax event="change" update="hiddingPanel"/>
</p:selectBooleanCheckbox>
<h:panelGroup id="hiddingPanel">
<p:commandButton id="doOpt1" rendered="#{bean.opt1 and !bean.opt2}"
actionListener="#{bean.readFile}" ajax="false" />
<p:fileDownload value="#{downloadBean.content}" />
<f:param name="reportType" value="REPORT1"/>
</p:commandButton>
<p:commandButton id="doOpt1" rendered="#{!bean.opt1 and bean.opt2}"
actionListener="#{bean.readFile}" ajax="false" />
<p:fileDownload value="#{downloadBean.content}" />
<f:param name="reportType" value="REPORT2"/>
</p:commandButton>
</h:panelGroup>
</h:form>
Thanks for any suggestions!
Regards.
every button click display panelGroup component(it contains 3 components).how to do it using jsf or richfaces
<h:form id="autoId">
<h:panelGroup id="pg1" columns="3" >
<rich:autocomplete mode="client" minChars="1" autofill="false"
selectFirst="false"
autocompleteMethod="#{autocompleteBean.autocomplete}"
autocompleteList="#{autocompleteBean.suggestions}"
/>
<h:inputText value=""/>
<h:inputText value=""/>
</h:panelGroup>
<a4j:commandButton value="show pg" />
</h:form>
when clicking on commanButton i like to show panelGroup
how to do it
My problem consists in deleting an item from data table. When i click on the button delete a confirm Dialog will appear to confirm removing the row from database. If so, the data will be removed but the data table isn't updated unless i logout and login and if i select another item it won't be even deleted.
<h:form id="form">
<p:panel id="panelform" header="Databases" >
<p:dataTable value="#{dataMB.customersDatas}" var="item" id="datas" rowsPerPageTemplate="5,10,15,20,25,30" paginator="true" rows="10" filteredValue="#{dataMB.filteredDatas}" selectionMode="single" rowKey="#{item.id}"selection="#{dataMB.selectedData}">
<p:ajax event="rowSelect" update=":form:dataView, :form:deleteButton, :form:viewButton" listener="#{dataMB.onRowSelect}"/>
</p:dataTable>
<p:panel>
<p:commandButton style="width: 8%;height: 100%" id="viewButton" value="View" oncomplete="dataDialogView.show()" disabled="#{dataMB.disabled}" icon="ui-icon-search" title="data details"/>
<p:commandButton style="width: 8%;height: 100%" id="deleteButton" value="Delete" oncomplete="deleteDialog.show()" disabled="#{dataMB.disabled}" icon="ui-icon-trash"/>
</p:panel>
</p:panel>
</h:form>
<p:confirmDialog style="position: absolute; width: 50px; border-color: blue" id="deleteData" message="Your Database Will be completely removed . Are you sure? " appendToBody="true" header="Delete Data" severity="alert" widgetVar="deleteDialog">
<h:form>
<p:commandButton id="confirm" style="width: 25%;height: 100%" value="Confirm" actionListener="#{dataMB.deleteData()}" update=":form:datas" ajax="true" oncomplete="deleteDialog.hide(); purchase.hide();" >
</p:commandButton>
<p:commandButton id="cancel" style="width: 25%;height: 100%" value="Later" onclick="deleteDialog.hide();" type="button" />
</h:form>
</p:confirmDialog>
deleteData() method in my sessionScoped managed Bean
public String deleteData() {
logger.log(Level.SEVERE, "*****delete Data***** ");
dataBusinessLocal.deleteData(selectedData);
return "datalist";
}
JSF is session based. To synchronize the state between client (browser) and server, JSF uses a hidden field javax.faces.ViewState. Right now, you are using two forms on the given page:
Clicking Action-Button on Form one
confirming on form two with updating the data table of form one
So, the hidden input field viewState isn't accurate any longer. Two ways I would possibly try:
Does the confirm-box have to be fancy JSF or does a javascript solution the job as well?
<p:commandButton id="deleteButton"
value="Delete"
disabled="#{dataMB.disabled}" icon="ui-icon-trash"
actionListener="#{dataMB.deleteData}"
onclick="if (!confirm('really delete?')) { return false;}" />
might do a similar job.
Possibility two: just rerender the whole form or the panel panelform instead of just the data table. This way a new javax.faces.ViewState should be rendered and the form works fine again.
Also, add a <h:messages /> somewhere in and update it on every step. In case there is a unexpected error, this might show it on the UI.
Hope that helps...
Message: 'PrimeFaces' is undefined,
Message: Object expected:
This error appears on IE8 especially when there is Accordion panel.After refreshing the page there is no error. Accordion panel basically does not work on IE on initial load when accordion panel has data table command buttons and confirm dailogues insides each tab.Can any body have a work around on this. I am using using prime faces 3.4, jsf2 with myfaces
<p:accordionPanel value="#{testBean.systems}" var="system" dynamic="true">
<p:tab title="#{system.name}" id="systemId">
<p:commandButton process="#this" value="edit" icon="ui-icon-pencil" styleClass="btn-primary" style="margin-left:734px;" action="#{testBean.edit}">
<f:setPropertyActionListener target="#{testBean.formBean}" value="#{system}"></f:setPropertyActionListener>
</p:commandButton>
<p:commandButton value="delete" icon="ui-icon-trash" styleClass="btn-primary" style="width:70px;" oncomplete="confirmDeleteDialog.show()"/>
<p:confirmDialog message="message" width="200"
showEffect="explode" hideEffect="explode"
header="Confirm" severity="alert" widgetVar="confirmDeleteDialog">
<p:commandButton process="#this" value="#{msg.EditSystem_confirmAnswer1}" action="#{testBean.deleteSystem}" oncomplete="confirmDeleteDialog.hide()">
<f:setPropertyActionListener target="#{testBean.formBean}" value="#{system}"></f:setPropertyActionListener>
</p:commandButton>
<p:commandButton value="#{msg.EditSystem_confirmAnswer2}" onclick="confirmDeleteDialog.hide()" type="button" />
</p:confirmDialog>
<p:dataTable id="dataTable" var="tester" value="#{system.studs}" rowKey="#{tester.id}">
<p:column id="serName" sortBy="#{tester.name}" headerText="#{msg.AddService_serName}">
<p:commandLink value="#{tester.name}" immediate="true" process="#this" action="#{testBean1.edit}">
<f:setPropertyActionListener target="#{testBean1.testId}" value="#{tester.id}"/>
<f:setPropertyActionListener target="#{testBean1.testId2}" value="#{tester.desc}"/>
<f:setPropertyActionListener target="#{testBean1.testId3}" value="#{tester.name}"/>
</p:commandLink>
</p:column>