I want that the filter is already activated when the page is loaded but I don't find any attribute that let me do that. The selectItem "Not Finished" is the one that should be activated. Here is my code:
<ui:define name="columnFinished">
<p:column filterBy="#{tarea.hasBeenFinished()}"
headerText="#{msgs.fechaFinalizacion}" filterMatchMode="equals">
<f:facet name="filter">
<p:selectOneButton onchange="PF('tasksTable').filter()">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="Not Finished" itemValue="false" />
</p:selectOneButton>
</f:facet>
<h:outputText value="#{userBean.formatDate(tarea.finished)}" />
</p:column>
</ui:define>
You add value="false" as attribute to the p:selectOneButton, this way when the page is loaded, Not Finished is set as default value for the filter
Related
I 'record' objects and I put them in a datatable. A record has a boolean value 'Ignored', my idea is to make a filter so that it either shows all ignored records or everything. Here is my code:
<p:column headerText="Status" filterMatchMode="equals" filterBy="#{record.ignored}">
<f:facet name="filter">
<p:selectOneButton onchange="PF('logTable').filter()">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="Ignored" itemValue="#{record.ignored}" />
</p:selectOneButton>
</f:facet>
<h:outputText value="#{record.status}" />
</p:column>
For some reason it is not working properly which i could not find, after searching for some examples online.
The item value for this item
<f:selectItem itemLabel="Ignored" itemValue="#{record.ignored}" />
should be either true or false since that is the condition that will be check during the filtering of the records
<f:selectItem itemLabel="Ignored" itemValue="true" />
I'm working with a <p:overlayPanel> that includes a couple of <p:selectOneMenu>s, as well as several other components. When the <p:selectOneMenu>s are opened, some of the fields fall outside of the <p:overlayPanel>, and clicking on them causes the panel to close. (See image below).
.
.
.
One solution would be to modify the <p:overlayPanel> as follows:
dismissable="false"
showCloseIcon="true"
Another would be to modify the <p:selectOneMenu>:
height="50"
I'm looking for some options for solutions that are as simple as possible and preferably don't involve a change to the UI (the above solutions both change the UI). Is there a way to keep the <p:overlayPanel> open when a click outside of it falls within one of its <p:selectMenu>s?
More Complete Code
<p:overlayPanel styleClass="col-settings-panel"
id="colSettingsPanel"
for="columnSettingsBtn"
hideEffect="fade"
widgetVar="wvcolSettingsPanel"
rendered="#{empty rendered ? 'true' : rendered}" >
<p:pickList id="pickList"
value="#{fileSearchPersonalizationBean.columns}"
var="column"
showSourceFilter="true"
itemLabel="#{column}"
itemValue="#{column}"
itemDisabled="#{column eq 'Ref No'}">
<p:ajax event="transfer" listener="#{fileSearchPersonalizationBean.onTransfer}" update="pickList availableCount selectedCount selectSortBy" />
<f:facet name="sourceCaption">
<h:outputText value="Available Columns ("/>
<h:outputText id="availableCount" value="#{fileSearchPersonalizationBean.sourceCount}"/>
<h:outputText value=")"/>
</f:facet>
<f:facet name="targetCaption">
<h:outputText value="Selected Columns ("/>
<h:outputText id="selectedCount" value="#{fileSearchPersonalizationBean.targetCount}"/>
<h:outputText value=")"/>
</f:facet>
</p:pickList>
<p:panelGrid columns="1">
<p:outputPanel styleClass="col-settings-panel-option">
<h:outputLabel value="Sort By: " />
<p:selectOneMenu id="selectSortBy"
value="#{fileSearchPersonalizationBean.sortBy}" >
<p:ajax listener="#{fileSearchPersonalizationBean.sortByChanged}" />
<f:selectItems id="sortByList" value="#{fileSearchPersonalizationBean.columns.target}" />
</p:selectOneMenu>
</p:outputPanel>
<p:outputPanel styleClass="col-settings-panel-option">
<h:outputLabel value="Items per Page:"/>
<p:selectOneMenu id="selectRows" value="#{fileSearchPersonalizationBean.sRows}" >
<f:selectItem itemLabel="10" itemValue="10" />
<f:selectItem itemLabel="25" itemValue="25" />
<f:selectItem itemLabel="50" itemValue="50" />
<f:selectItem itemLabel="100" itemValue="100" />
</p:selectOneMenu>
</p:outputPanel>
</p:panelGrid>
<p:panelGrid styleClass="toolbar" columns="2">
<p:outputPanel>
<p:commandButton styleClass="btn-secondary"
id="loadDefaults"
value="Reset Defaults"
update="selectSortBy pickList selectRows"
actionListener="#{fileSearchPersonalizationBean.loadDefaultVO}" />
</p:outputPanel>
<p:outputPanel styleClass="toolbar-right">
<p:commandButton styleClass="btn-secondary"
id="columnClose"
value="Cancel"
actionListener="#{fileSearchPersonalizationBean.panelCancel}"
immediate="false">
<f:attribute name="panelId" value="#{formId}:colSettingsPanel" />
</p:commandButton>
<p:commandButton styleClass="btn-primary"
id="columnSubmit"
value="Save & Apply"
actionListener="#{fileSearchPersonalizationBean.panelSave}"
oncomplete="refreshSearchResults();" >
<f:attribute name="panelId" value="#{formId}:colSettingsPanel" />
</p:commandButton>
</p:outputPanel>
</p:panelGrid>
</p:overlayPanel>`
I am creating a selectonemenu using Primefaces and JSF.
I want to appear a message saying "Choose one of the options". How can I do that?
This is the code:
<!--Gender-->
<p:selectOneMenu id="gender" value="#{users.gender}" required="true"
requiredMessage="Choose one of the options">
<f:selectItem itemLabel="Choose gender" itemValue="#{null}" />
<f:selectItem itemLabel="Male" itemValue="Male" />
<f:selectItem itemLabel="Female" itemValue="Female" />
</p:selectOneMenu>
Thanks
adding below on the submit button will work fine as well.
ajax="false"
*********************edited**********
As you requested, please find below block of codes that works fine for me ::
<h:form>
<p:panelGrid style="margin-top:5px;width:730px;">
<f:facet name="header">
<p:row >
<p:column colspan="20">Select Company</p:column>
</p:row>
</f:facet>
<p:row>
<p:column>
<p:selectOneMenu id="companyMenu" value="#{clientList.clientCode}"
style="width:550px;margin:5px;text-color:black" required="true"
requiredMessage="Please select a company !">
<f:selectItem itemLabel="Select a Company" noSelectionOption="true"
itemValue="#{null}" />
<f:selectItems value="#{clientList.clients.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}" >
</f:selectItems>
</p:selectOneMenu>
</p:column>
<p:column>
<p:commandButton value="Submit" style="margin:5px;" action="#
{viewPayment.companyDetails(clientList.clientCode)}" ajax="false"/>
</p:column>
</p:row>
</p:panelGrid>
</h:form>
You can use :
if (users.getGender()==null) {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
"Choose one of the options",
"Choose one of the options"));
}
SOLVED.I forgot to add the line <p:message for="gender" /> to the code. Thanks.
i am beginner in JSF ,i have a problem with selectonemenu item.When i choose the an item ,for example ' FirstLabel',outputpanel should be shown.However ,selectone menu does not update my choice.I use primefaces 3.1 library.How can i solve this problem.Thanks for helps.
<p:selectOneMenu value="#{denemeView.str}" effect="fold" editable="true" >
<f:selectItem itemLabel="Please choose!." itemValue="" />
<f:selectItem itemLabel="FirstLabel" itemValue="1" />
<f:selectItem itemLabel="SecondLabel" itemValue="2" />
<p:ajax process="#this" update=":Form2:panel1"/>
<p:ajax process="#this" update=":Form2:panel2"/>
</p:selectOneMenu>
</p:outputPanel>
<p:outputPanel id="panel1" rendered="#{denemeView.str=='1'}">
<h:outputText value="Output: * " />
<p:inputText id="out" value="#{denemeView.islem}" />
</p:outputPanel>
<p:outputPanel id="panel2" rendered="#{denemeView.str=='2'}">
<h:outputText value="True choice! " />
</p:outputPanel>
If a JSF component has rendered="false" set then it's not redered (the component object is not present in the object tree) and cannot be updated using <p:ajax update="someId"/> or <f:ajax render="someId"/>. What you need to do is wrap these two panels in an outer panel and update that one. Something like this:
<p:ajax process="#this" update="outerPanel"/>
...
<p:outputPanel id="outerPanel">
<p:outputPanel id="panel1" rendered="#{denemeView.str=='1'}">
<h:outputText value="Output: * " />
<p:inputText id="out" value="#{denemeView.islem}" />
</p:outputPanel>
<p:outputPanel id="panel2" rendered="#{denemeView.str=='2'}">
<h:outputText value="True choice! " />
</p:outputPanel>
</p:outputPanel>
See here for a similar problem.
So heres the skinny of it. I have a rendered tag on my selectOneMenu. I've tried it in various ways, this last one updating the form in the boolean checkbox with the "#form". I am all out of ideas, been working on it for a few days. What am I missing so I can render/unrender based on the selection of the checkbox? Thanks.
<rich:dataTable id="catalogview" width="100%" style="width: 100% !important"
columnClasses="lcolumnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog"
value="#{pcnAlerts.notifications}" var="pcn" rows="20"
headerClass="headerCatalog" styleClass="table1" footerClass="footer_td" >
<h:column>
<h:selectBooleanCheckbox value="#{pcn.checked}" update="#form" >
<f:ajax listener="#{pcnAlerts.selectItem}" render=":popupForm:popupPanelContents" />
</h:selectBooleanCheckbox>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Status" />
</f:facet>
<h:outputText value="#{pcn.status}" />
<h:selectOneMenu id="StatusMenu" value="#{pcnAlerts.newStatus}" rendered="#{pcn.checked}">
<a4j:ajax update="StatusMenu" listener="#{pcnAlerts.saveStatus()}" />
<f:selectItem itemValue="" itemLabel="New" />
<f:selectItem itemValue="Pending" itemLabel="Pending" />
<f:selectItem itemValue="Complete" itemLabel="Complete" />
<f:selectItem itemValue="Archive" itemLabel="Archive" />
<f:selectItem itemValue="Disregard" itemLabel="Disregard" />
</h:selectOneMenu>
</h:column>
</rich:dataTable>
You must also update catalogview in order to render the components inside the table. Also, make sure your <rich:dataTable> is inside a <h:form>:
<h:form id="frmCatalog">
<rich:dataTable id="catalogview" value="#{pcnAlerts.notifications}" var="pcn">
<h:column>
<h:selectBooleanCheckbox value="#{pcn.checked}">
<f:ajax listener="#{pcnAlerts.selectItem}"
render=":popupForm:popupPanelContents :frmCatalog:catalogview" />
</h:selectBooleanCheckbox>
</h:column>
</rich:dataTable>
</h:form>