I'm using PrimeFaces 3.5 , and now i want to ask the user to input or choose some data in my dialog (choose oneSelectMenu, or insert data in inputTextarea). I also use table to arrange the UI.
But any value from user in my dialog is not send to my backing bean.
I think it's because i used it in a dialog.
I tried to move one of my oneSelectMenu outside the dialog, and it works fine!
Any body know what's wrong? Any response will be much appreciated.
My backing bean is kind of standard getter and setter.
(I think nothing wrong with my backing bean because it works fine outside the dialog)
And this is my xhtml code :
<p:dialog id="dlgNew" header="New Action Item" widgetVar="dlg1" modal="true" resizable="false"
width="40%" height="55%" appendToBody="true">
<table>
<tr>
<td><p:outputLabel value="Detail"/></td>
<td>:</td>
<td><p:inputTextarea rows="5" cols="40" value="#{aiBean.detail}"/></td>
</tr>
<tr>
<td><p:outputLabel value="Status"/></td>
<td>:</td>
<td><p:selectOneMenu effect="fade" value="#{aiBean.status}">
<f:selectItem itemLabel="Not Started" itemValue="Not Started" />
<f:selectItem itemLabel="On Progress" itemValue="On Progress" />
<f:selectItem itemLabel="Finished" itemValue="Finished" />
</p:selectOneMenu>
</td>
</tr>
<tr>
<td></td><td></td>
<td>
<p:commandButton value="Add" action="#{aiBean.insertAi}"/>
<p:commandButton value="Cancel" onclick="dlg1.hide()"/></td>
</tr>
</table>
Move the p:dialog out of h:form if its in any.
put h:form inside the p:dialog.
<p:dialog id="dlgNew" header="New Action Item" widgetVar="dlg1" modal="true" resizable="false"
width="40%" height="55%" appendToBody="true">
<h:form>
...
...
</h:form>
</p:dialog>
Related
I have a dialog which is contains two listboxes, one checkbox and one button. I try to pass values of these components to backing bean.
<p:dialog header="Add" widgetVar="dlgAdd" resizable="false"
id="dlgAddId" showEffect="fade" modal="true">
<h:form id="dlgAddForm">
<p:panelGrid columns="2">
<p:outputLabel>Name*</p:outputLabel>
<p:selectOneMenu id="addname" value="#{notificationsSettingManagedBean.customerUserEmailSetting.userNameSurname}" effect="fold">
<f:selectItems value="#{notificationsSettingManagedBean.customerUserNameSurnameList}" />
</p:selectOneMenu>
<p:outputLabel>Email-ID*</p:outputLabel>
<p:selectOneMenu id="addsurname" value="" effect="fold">
<f:selectItems value="#{notificationsSettingManagedBean.customerUserEmailsList}" />
</p:selectOneMenu>
</p:panelGrid>
<p:panel>
<div align="center">
<p:outputLabel>Email Notifications</p:outputLabel>
</div>
</p:panel>
<p:panelGrid columns="2" style="width: 100%;text-align: center;">
<p:outputLabel>Order Submitted</p:outputLabel>
<p:selectBooleanCheckbox value="#{notificationsSettingManagedBean.customerUserEmailSetting.orderSubmit}"/>
</p:panelGrid>
<div align="center">
<p:commandButton
actionListener="#{notificationsSettingManagedBean.saveCustomerEmailSettings}"
immediate="true" value="Save" ajax="true"
oncomplete="dlgAddId.hide();" />
</div>
</h:form>
</p:dialog>
On notificationsSettingManagedBean, i create customerUserEmailSetting object which is contains get and set methods of userNameSurname,customerUserEmailsList and ordersubmit.
Problem is when try to get this data on saveCustomerEmailSettings method on backing bean i see that these data are null. How can i pass them to backing bean?
I am trying to put a p:commandButton inside a overlayPanel, to submit the information of a h:form and redirect to another view. So, I use the property action of the button to perform this operation. I have a managed bean associated with this view but the function used for this purpose is never reached. Can u help me?
Here is the code:
advancedSearch-form.xhtml
<h:form>
<h:panelGrid width="100%">
<h:column>
....
</h:column>
....
<p:commandButton value="Submit" action="#{searchForm.save}">
</p:commandButton>
</h:panelGrid>
In another xhtml:
<h:form>
<div>
...
<div class="menu-search">
<p:commandButton id="advancedSearch" icon="ui-icon-carat-1-s" styleClass="ui-search-button" type="button"/>
<p:overlayPanel id="advancedSearchPanel" styleClass="ui-advanced-search-overlay" for="advancedSearch" hideEffect="fade" my="right top" dynamic="true" dismissable="false">
<ui:include src="/search/advancedSearch-form.xhtml"/>
</p:overlayPanel>
</div>
...
</div>
After looking over the properties of overlay, I solved this question by removing the dynamic property of overlaypanel.
I 'm using the tag ui:repeat to display a list of pictures and their titles.
My code is:
<p:dialog id="idSchemaDlg5" widgetVar="schemaDlg" position="10" resizable="true" modal="true" header="Schéma des composants">
<h:panelGrid columns="1">
<ui:repeat value="#{imageStreamer.pictureNamesList}" var="imageName" >
<h:panelGrid columns="#{imageStreamer.pictureNamesList.size()}">
<p:graphicImage value="#{imageStreamer.image}" >
<f:param name="pictureName" value="#{imageName}" />
</p:graphicImage>
<h:outputText value="#{imageName}"/>
</ui:repeat>
</h:panelGrid>
</p:dialog>
I would to display the list of pictures horizontally but the list of pictures with this code was vertically displayed.
Any help is welcome.
I would to have this structure in output <table><tbody><tr><td><img1/><title1/></td><td><img2/><title2/></td><img3/><title3/><td></td></tr></table>
The <ui:repeat> inside <h:panelGrid> won't generate physically multiple table cells. It will generate only one table cell. In fact, each immediate child UI component of <h:panelGrid> counts as a single table cell. The <ui:repeat> is an UI component.
You need <c:forEach> instead. It's a taghandler and runs during building JSF component tree instead of during generating HTML output. It generates physically multiple JSF components, in contrary to <ui:repeat> which represents physically one JSF component which is reused everytime during generating HTML output.
<h:panelGrid columns="#{imageStreamer.pictureNamesList.size()}">
<c:forEach items="#{imageStreamer.pictureNamesList}" var="imageName">
<h:panelGroup>
<p:graphicImage value="#{imageStreamer.image}">
<f:param name="pictureName" value="#{imageName}" />
</p:graphicImage>
<h:outputText value="#{imageName}"/>
</h:panelGroup>
</c:forEach>
</h:panelGrid>
(note that you need to wrap the image and the text in a <h:panelGroup> to represent a single table cell)
Or, if you insist in using <ui:repeat>, then you have to write down the desired HTML output yourself.
<table>
<tbody>
<tr>
<ui:repeat value="#{imageStreamer.pictureNamesList}" var="imageName">
<td>
<p:graphicImage value="#{imageStreamer.image}">
<f:param name="pictureName" value="#{imageName}" />
</p:graphicImage>
<h:outputText value="#{imageName}"/>
</td>
</ui:repeat>
</tr>
</tbody>
</table>
See also:
JSTL in JSF2 Facelets... makes sense?
create table columns dynamically in JSF
you must change the order of the h:panelGrid and p:graphicImage. because you repeat the creation of the h:panelGrid with size() as number of columns. your code becomes:
<p:dialog id="idSchemaDlg5" widgetVar="schemaDlg" position="10" resizable="true" modal="true" header="Schéma des composants">
<h:panelGrid columns="#{imageStreamer.pictureNamesList.size()}">
<ui:repeat value="#{imageStreamer.pictureNamesList}" var="imageName" >
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td> <p:graphicImage value="#{imageStreamer.image}" >
<f:param name="pictureName" value="#{imageName}" />
</p:graphicImage>
</td>
</tr>
<tr>
<td ><h:outputText value="#{imageName}"/></td>
</tr>
</table>
</ui:repeat>
</h:panelGrid>
</p:dialog>
On my page galleria was working fine before adding captcha to the code.
After adding captcha to the code galleria is not displaying on page.
I tried to keep both captcha on different form but still it is not working.
Captcha is working fine.
I've no idea what is problem with this.
<h:form id="frmTest">
<center >
<br/><br/>
<table width="70%" border="0">
<tr>
<td width="70%" align="center">
<p:panel >
<p:galleria value="#{LoginBean.imgList}"
var="image" effect="slide"
effectSpeed="1000"
panelWidth="500" panelHeight="300"
frameWidth="100" frameHeight="70"
rendered="true">
<p:graphicImage value="../resources/images/{image}"/>
</p:galleria>
</p:panel>
</td>
<td width="30%">
<p:panel>
<p:commandButton id="btnShowCaptcha"
process="#form"
onclick="captchaDlgWar.show()"
value="Show Captcha"/>
</p:panel>
</td>
</tr>
</table>
</center>
<p:dialog widgetVar="captchaDlgWar" id="capchaDlgId"
hideEffect="explode" showEffect="clip"
modal="true" closable="true" resizable="false"
header="Prove you are human..." width="360" height="190">
<h:panelGrid columns="1">
<p:captcha label="Captcha"
id="captchaId"
language="tr"
required="true"/>
<p:commandButton id="btnContinue"
ajax="false"
value="Continue"
action="#{MyBean.onContinueAction}"/>
</h:panelGrid>
</p:dialog>
</h:form>
MyBean
public String onContinueAction() {
RequestContext.getCurrentInstance().execute("captchaDlgWar.hide()");
return "somePage.xhtml";
}
Thnx.
try taking your dialog outside of your form and add another form inside your dialog
so you'll have one dialog with galeria inside and another dialog inside your dialog make sure you don't nest forms
<h:form.... <p:galleria...</h:form>
and
<p:dialog><h:form.... <p:captcha ...</h:form></p:dialog>
Also
I'd try to use p:panelGrid Primefaces PanelGrid instead of the table
I do not know if this is possible using just primefaces and JSF but I have a panel, which is collapsed on View Entry. I can open the Panel which has a checkbox that triggers an update of the Panel.
The problem is that when the panel is updated by Ajax, the Panel is collapsed again. But I want to retain the current open status of the Panel. It should no close on update. Is this possible?
I use PF 3.2 and JSF2.1
<p:fieldset style="width:200px;height:300px;overflow:auto;">
<h:outputLabel value="Available Applications"
style="font-weight: bold;font-size: 14px;" />
<br />
<br />
<h:panelGroup>
<ui:repeat var="category"
value="#{epsEditController.subscriptionCategoryVOs}">
<p:panel header="#{category.applicationCategory.name}"
id="panell" toggleable="true" closable="false" toggleSpeed="500"
collapsed="true"
widgetVar="panel_#{category.applicationCategory.name}">
<h:panelGrid columns="2" border="0">
<h:outputLabel value="Select all"
style="font-weight: bold;float:left;" />
<p:selectBooleanCheckbox value="#{category.allSelected}">
<p:ajax event="change"
listener="#{epsEditController.selectionChanged(category)}"
update="panell" />
</p:selectBooleanCheckbox>
</h:panelGrid>
<ui:repeat var="subcat"
value="#{category.applicationSubcategoryVOs}">
<p:selectBooleanCheckbox value="#{subcat.selected}"
title="#{subcat.applicationSubcategory.name}"
itemLabel="#{subcat.applicationSubcategory.name}" />
</ui:repeat>
</p:panel>
</ui:repeat>
</h:panelGroup>
</p:fieldset>
The reason the panel was collapsed after each update is caused by using a static collapsed="true" on the panel. This can be fixed in one of two ways
Just updating the content of the panel and not the panel
Keeping track of the state of collapsed state of the panel via ajax and use that state as the value of the collapsedattribute
Updating the content
By putting the form within the panel and only updating that form you effectively update the content instead of the panel. This makes sure that only the form is refreshed and the panel state is kept intact.
<p:panel header="#{category.applicationCategory.name}" id="panell"
toggleable="true" closable="false" toggleSpeed="500"
collapsed="true"
widgetVar="panel_#{category.applicationCategory.name}">
<h:form id="epsAppForm">
<h:panelGrid columns="2" border="0">
<h:outputLabel value="Select all"
style="font-weight: bold;float:left;" />
<p:selectBooleanCheckbox value="#{category.allSelected}">
<p:ajax event="change"
listener="#{epsEditController.selectionChanged(category)}"
update="#form" />
</p:selectBooleanCheckbox>
</h:panelGrid>
........
</h:form>
</p:panel>
Using EL instead of a fixed value
You can put EL in the collapsed attribute instead of the fixed collapsed="true". Something like
collapsed="#{myBean.toggleStates[category.applicationCategory]}"
You can then keep track of the state of the pannel via ajax calls
<p:ajax event="toggle" listener="#{myBean.toggleState(category.applicationCategory)" />
...'myBean' code:
Map<ApplicationCategory, boolean> toggleStates = new HashMap<>();
... prepopulate toggleStates on #init or something
public void toggleState(ApplicationCategory myCategory) {
toggleStates.put(myCategory, !(toggleStates.get(myCategory));
}