Sarz
Sarz

Reputation: 1976

PrimeFaces UI SelectOneButton

I am using Primefaces 4.0 with JSF 2.0

my requirement is to do some specific task behind (ON / OFF) selection button, my code is like

<h:form>
    <h:panelGrid>
        <p:selectOneButton value="#{buttonBean.number}">
            <f:selectItem itemLabel="ON" itemValue="1" />
            <f:selectItem itemLabel="OFF" itemValue="0" />
        </p:selectOneButton>
    </h:panelGrid>
</h:form>

for now UI and all is fine but, value is not passed on click to the bean which is buttonBean.number unless i submit it using a submit button.

My aim is to pass and set number = 0 and number = 1 by only click not submit it, where "0" is for Off and "1" is for On,

Upvotes: 1

Views: 2667

Answers (1)

Sarz
Sarz

Reputation: 1976

Another solution without submit

<p:selectOneMenu id="listFilter" value="#{sess.selectedFileId}">
    <p:ajax update="mytable" listener="#{beanBacking.fileChanged()}" partialSubmit="true" />
    <f:selectItem itemLabel="-- ALL --" itemValue="#{null}" />
    <f:selectItems value="#{beanBacking.fileList}" />
</p:selectOneMenu>

<p:ajax /> learn p:ajax more HERE, from this page will not even refersh.

Upvotes: 1

Related Questions