简体   繁体   English

在加载时使用 javascript 刷新 jsp 面板中的 h 选择菜单

[英]refresh h selectonmenu in jsp panel by using javascript on load

I have a rich table panel with many panels containing a jsp file.我有一个丰富的表格面板,其中包含许多包含 jsp 文件的面板。 I have one jsp file like this:我有一个像这样的 jsp 文件:

<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).我的问题是当我 selectfruit1 或fruit2 或fruit3 并单击另一个面板时,当我返回此面板时,我有最后一个select 存在(fruit1 或fruit2 或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.当我将 go 转到另一个面板并返回此面板时,我想清空用户选择,select 选择必须为空。 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如何刷新我的 jsp 页面侧 javascript 以删除最后一个 select 水果,默认情况下选择必须为空

The value is held in #{myBean.FruitId} .该值保存在#{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.您可以在面板中放置a4j:jsFunction<p:remoteCommand并从 javascript onbluronfocusonclick方法调用此 function This way, you can call any bean method and do a value setting as you want.这样,您可以调用任何 bean 方法并根据需要进行值设置。 Don't forget to give the remoteCommand a correct update="mypanelid"不要忘记给 remoteCommand 一个正确的update="mypanelid"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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