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" />
Related
I'm using primefaces and have a datatable that has 2 columns. One column is outputtext another one is selectOneMenu. I made editable selectOneMenu. Actually it's work but not properly. Default value of selectItem is shown null but ı want it to show first value as default value. How can I make it?
<p:dataTable id="cellEditingTable" var="message"
value="#{messageTableController.menuList}" paginator="true"
paginatorPosition="bottom" editable="true" editMode="cell">
<p:column>
<p:selectOneMenu id="menu" value="#{messageTableController.selected}"
style="width:96%" effect="fold" editable="true">
<f:selectItem itemLabel="#{message.assign}"
itemValue="#{message.assign}" />
<f:selectItem itemLabel="#{message.combo}"
itemValue="#{message.combo}" />
</p:selectOneMenu>
</p:column>
</p:dataTable>
I change selectOneMenu's value to first ItemValue. So when run the program, first ItemValue picked selected item as a default.
<p:selectOneMenu id="menu" value="#{message.assign}"
style="width:97%" editable="true">
<f:selectItem itemLabel="#{message.assign}"
itemValue="#{message.assign}" />
<f:selectItem itemLabel="#{message.combo}"
itemValue="#{message.combo}" />
</p:selectOneMenu>
Add noSelectionOption to the first selectItem
<f:selectItem itemLabel="#{message.assign}"
itemValue="#{message.assign}" noSelectionOption="true" />
May be late to answer this.
If you use editable="true" then while rendering in the browse, it will render as textbox.
Remove the editable="true" then the default value will be selected.
If you want to provide the filter option in the selectOneMenu, use filter="true"
<p:selectOneMenu id="menu" value="#{message.assign}"
style="width:97%" filter="true">
<f:selectItem itemLabel="#{message.assign}"
itemValue="#{message.assign}" />
<f:selectItem itemLabel="#{message.combo}"
itemValue="#{message.combo}" />
</p:selectOneMenu>
Based on the editable property, it will render in browser as below.
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
I am using prime faces in my project. I am generating a pull down by using p:ajax and its working fine for me. But i have notice a problem that is if i select ---select one-- my pull down which i have generated by p:ajax is not resetting to default .
My code is:
<p:selectOneMenu id="propExam" value="#{rollNoBean.examination}"
converter="omnifaces.SelectItemsConverter" editable="false"
required="true" label="Examination Applied For" styleClass="dropdownWidth">
<f:selectItem itemLabel="---Select One---" itemValue="0" />
<f:selectItems value="#{rollNoBean.testExamNames}" var="test" itemLabel="#{test.name}" itemValue="#{test}" noSelectionOption="true" />
<p:ajax listener="#{rollNoBean.readFilterByExamination(rollNoBean.examination.id)}"
update="degreeList centerId" />
</p:selectOneMenu>
<h:outputText value="Select Filter Category :" />
<p:selectOneMenu id="degreeList"
value="#{rollNoBean.filter}" editable="false"
converter="omnifaces.SelectItemsConverter" required="true"
label="Please Select degree" styleClass="dropdownWidth">
<f:selectItem itemValue="" itemLabel="---Select One---" />
<f:selectItems value="#{rollNoBean.degreeNames}"
var="degree" itemLabel="#{degree.name}" itemValue="#{degree}" />
</p:selectOneMenu>
and my bean code is:
public List<Filter> readFilterByExamination(int id)
{
if(id!=0)
{
return degreeNames=examinationDetailsService.readFilterByExamination(id);
}
return degreeNames=new ArrayList<Filter>();
}
Please give suggetion
I want to disabled department field based on employeeno.But,I want department value in bean.When,I using disabled value getting null in bean but without using disabled no problem...
<h:outputText value="Employee No"/>
<p:selectOneMenu value="#{salarypromotionBean.salarypromotiondto.employeeNo}" id="emp" style="width:163px;">
<f:selectItem itemLabel="select" itemValue="0" />
<f:selectItems value="#{salarypromotionBean.empid}"/>
<p:ajax event="change" listener="#{salarypromotionBean.currentSalaryAmount}" update="salaryIncrement,empN,empDoj,basic,da,empNewDesig,commonSalaryIncrement"/>
</p:selectOneMenu>
<h:outputText value="Department" />
<p:selectOneMenu value="#{salarypromotionBean.salarypromotiondto.department}" id="empDept" disabled="#{salarypromotionBean.designationDiaspleValue}"
style="width:163px;">
<f:selectItems value="#{salarypromotionBean.deptname}" />
</p:selectOneMenu>
You can do this.
<p:selectOneMenu value="#{salarypromotionBean.salarypromotiondto.department}" id="empDept" rendered="#{!salarypromotionBean.designationDiaspleValue}"
style="width:163px;">
<f:selectItems value="#{salarypromotionBean.deptname}" />
</p:selectOneMenu>
<p:inputText value="#{salarypromotionBean.salarypromotiondto.department}" readonly="true" rendered="#{salarypromotionBean.designationDiaspleValue}"/>
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>