简体   繁体   中英

refresh h selectonmenu in jsp panel by using javascript on load

I have a rich table panel with many panels containing a jsp file. I have one jsp file like this:

<rich:panel>
    <f:facet name="header">
        <h:outputText value="Traitement" />
    </f:facet>
    <h:panelGroup>
        <table style="width: 95%; border-spacing: 5px">

    <tr>
        <td><h:outputLabel value="Fruit list  : " /></td>
        <td>
          <h:selectOneMenu
                    id="list_fruit" style="width:288px;"
                    value="#{myBean.FruitId}">
                <f:selectItem itemValue="0" itemLabel="" />
                <f:selectItem itemValue = "1" itemLabel = "fruit 1" /> 
                <f:selectItem itemValue = "2" itemLabel = "fruit 2" /> 
                <f:selectItem itemValue = "3" itemLabel = "fruit 3" />
            </h:selectOneMenu>
        </td>
    </tr>
</table>
    </h:panelGroup>
</rich:panel>

My problem is when i select fruit1 or fruit2 or fruit3 and i click in another panel and when i return to this panel, i have the last select present(fruit1 or fruit2 or fruit3). I want to empty user selection when I go to another panel and i return to thius panel, the select choice must have empty. How can i do refresh my jsp page side javascript to delete the last select of fruit and the selection by default must have empty

The value is held in #{myBean.FruitId} . You have to clear this value.

You can put a a4j:jsFunction or a <p:remoteCommand in your panel and call this function from your javascript onblur , onfocus or onclick method. This way, you can call any bean method and do a value setting as you want. Don't forget to give the remoteCommand a correct update="mypanelid"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM