Issue in selectOneMenu in primefaces? - primefaces

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.

Related

Uncheck all p:selectManyCheckbox checkboxes from a p:selectOneRadio item

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.

scroll h:selectOneMenu jsf

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

jsf standard converter along with primefaces select one menu

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.

<p:selectOneMenu>, filter and converter

I have a menu with filter on. The value and label are both String. In this case, does the "converter" property have to be set? The reason I'm asking is that the filter function is not working if the "converter" is not provided. E.g.,
<p:selectOneMenu value="#{menuBean.selectedCountry}" filter="true" filterMatchMode="startsWith">
<f:selectItem itemLabel="Select One" itemValue=""/>
<f:selectItem itemLabel="US" itemValue="1"/>
<f:selectItem itemLabel="Spain" itemValue="2"/>
</p:selectOneMenu>
Thank you for your points and help!
You didn't specify your primefaces version but this is a bug in 3.4. You can set the height attribute of p:selectOneMenu or you can apply the following fix from here. SelectOneMenu with filter not working with less than 10 elements.

How do I embed a primefaces selectonemenu into a menubar?

I am trying to use primfaces' selectonemenu and menubar for navigation, however I am having trouble getting the menubar to display the selectOneMenu as it only seems to want to recognize tags and not tags. Any ideas?
menubar http://www.primefaces.org/showcase-labs/ui/menubar.jsf
selectOneMenu http://www.primefaces.org/showcase-labs/ui/selectOneMenu.jsf
Use a Toolbar instead of a Menubar:
<p:toolbar>
<p:toolbarGroup align="left">
<p:selectOneMenu>
<f:selectItem itemValue="Red" itemLabel="Red"/>
<f:selectItem itemValue="Blue" itemLabel="Blue"/>
<f:selectItem itemValue="Green" itemLabel="Green"/>
<!-- other components -->
</p:selectOneMenu>
</p:toolbarGroup>
</p:toolbar>
Produces: