I have a h:selectOneMenu element with elements from an array list
<h:selectOneMenu class="select_3" value="#{Bean.choosenList}"
valueChangeListener="#{Bean.getChoosenListId}">
<f:ajax render=":contact-form:choosenList :contact-form:list-contact-table :contact-form:error_mess"
execute="#this" event="valueChange" />
<f:selectItem itemValue="" itemLabel="" />
<f:selectItems value="#{Bean.userList}" var="l" itemLabel="#{l.listName}" itemValue="#{l.listId}" />
</h:selectOneMenu>
The list now loaded is paginated, I need to add more lists (append to the first list) each time the user scrolls down, I used to get scroll event on a div to get if it is scrolled, but with a select element this way won't work. Appreciate your help
Related
How could I Uncheck all checkboxes from selectManyCheckbox when choosing "No" from selectOneRadio
<p:selectOneRadio id="radio" value="#{myView.myObject.myBoolean}">
<f:selectItem itemLabel="Si" itemValue="#{true}"/>
<f:selectItem itemLabel="No" itemValue="#{false}"/>
<p:ajax process="radio" event="valueChange" update="#widgetVar(displayPanel)"/>
<p:ajax update="#this"/>
</p:selectOneRadio>
<p:panel widgetVar="displayPanel">
<p:outputPanel rendered="#{myView.myObject.myBoolean}">
<p:selectManyCheckbox widgetVar="mySelections" value="#{myView.myObject.myObjectList}" layout="grid" columns="8" styleClass="grid-checkbox">
<p:ajax update="#this"/>
<f:selectItems value="#{myView.things}" var="thing" itemLabel="#{thing.idThing}" itemValue="#{thing.thing}"/>
</p:selectManyCheckbox>
</p:outputPanel>
</p:panel>
As seen, update="#widgetVar(displayPanel)" will show the outputPanel when myBoolean is true and viceversa.
What I need to achieve is to uncheck all the already selected checkboxes (mySelections) when myBoolean is false (by selecting "No" from selectOneRadio above.
Possible? If so, Could you please show me how, I'm just starting on PrimeFaces.
Normally, the easiest way would be using the client side API uncheckAll. However, there is a bug. But, I've fixed it. So you can wait for PrimeFaces 12.0.0-RC3 or create a Monkey Patch.
A simple demo would be:
<p:selectOneRadio id="radio" value="#{testView.bool}"
onchange="if(this.value==='false'){PF('mySelections').uncheckAll()}">
<f:selectItem itemLabel="Si" itemValue="true"/>
<f:selectItem itemLabel="No" itemValue="false"/>
</p:selectOneRadio>
<p:selectManyCheckbox widgetVar="mySelections" value="#{testView.strings}">
<f:selectItems value="#{['a','b','c']}"/>
</p:selectManyCheckbox>
This eliminates the need to use Ajax.
p:selectOneMenu result itemlists are initially shows stick to selectOneMenu dropdown, As when I scroll using mouse scroller the result Itemlist moves up or down as I scroll the mouse.
This p:selectOneMenu I have in the dialog box.
This works fine if I use the h:selectOneMenu. The problem is in p:selectOneMenu (primeface 6.2 version).
I have tried with attribute PanelStyle="position:fixed;" but this not helped. The problem appears only in when I use mouse scroller.
Can somebody please guide me how to fix this.
<p:dialog header="Add User" widgetVar="addUserWidget" id="addUserWidgetId" modal="true">
<p:fragment>
<h:panelGrid columns="2" id="myGridPanelId" width="180px">
<h:panelGroup id="groupPan">
<p:selectOneMenu value="#{myBean.selectedUser}" style="width:140px;">
<f:selectItems
value="#{myBean.userLists}" id="userNameItem"
var="user" itemLabel="#{user.name}" itemValue="#{user.name}">
</f:selectItems>
<f:ajax event="change" execute="#this" render="groupPan" listener="#{myBean.userAdd()}" />
</p:selectOneMenu>
</h:panelGroup>
</h:panelGrid>
<h:panelGrid id="panelBtnGrid">
<p:commandButton ajax="true" value="Add" id="addBtnId" process="#this"
action="#{myBean.saveUser()}" />
</h:panelGrid>
</p:fragment>
</p:dialog>
The result Item list should stick to the p:selectOneMenu dropdown box.
I am working on a JSF page which has a dropdown based on selectOneMenu
<h:selectOneMenu id="speciality_unit" value="#{editCdc.selectedUnit}">
<f:selectItem itemValue="" itemLabel="Select Unit" />
<f:selectItems value="#{editCdc.listOfUnit}" />
</h:selectOneMenu>
The problem I am facing here is that whenever I select this dropdown, it shows the default option in the list along with other items. I.e. it shows "Select Unit" along with other units. I want to remove this "Select Unit" from the dropdown list. How I can do this?
Hide it using CSS.
<h:selectOneMenu ... styleClass="hideFirstOption">
select.hideFirstOption option:first-child {
display: none;
}
When the "select" option of the select one menu is selected, the default value is saved in DB as 0. Can I change this to null?
The value of select one menu is bound to a bean property. To achieve this, I have used the converter attribute of the select one menu component. But it does not seem to convert empty string to null. What am I missing?
<p:panelGrid columns="2" >
<p:outputLabel value="District" />
<p:selectOneMenu value="#{cJData.cJ.dC}" converter="javax.faces.Long">
<p:ajax listener="#{cJActionHandler.selectDC}"/>
<f:selectItem itemLabel="Select" itemValue="" />
<f:selectItems value="#{cJData.DCs}" var="coun"
itemLabel="#{coun.name}" itemValue="#{coun.id}" />
</p:selectOneMenu>
</p:panelGrid>
Use the following
<f:selectItem itemLabel="Select" itemValue="#{null}" />
As the docs of LongConverter#getAsObject say - this is the method which is called when you submit th value - the Long converter will convert only null to null.
I am using primefaces 3.2 and i have used selectOneMenu from primefaces.When i drag and drop somethine into the selectOneMenu box it displaying some url(for example drag and drop the image into the selectOneMenu).Text box allows that drag and drop but why selectOneMenu.How to avoid that.
<p:selectOneMenu value="#{buttonBean.number}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Option 1" itemValue="1" />
<f:selectItem itemLabel="Option 2" itemValue="2" />
<f:selectItem itemLabel="Option 3" itemValue="3" />
</p:selectOneMenu>
Primefaces 3.2 uses an html input to display the selected value.
If you can, update to 3.4. The helper input is gone, no this issue.
You can test it in the showcase.