当我从jsf xhtml页面的下拉列表中选择值(h:selectOneMenu)时,如何避免表单加载两次

时间:2014-01-02 10:39:23

标签: jsf

嗨,在下面的代码中,当我从下拉列表中选择值时(h:selectOneMenu),它将调用bean方法两次。并在前端打印两次。 下面是代码,

<h:body>
#{customerRoleFeature.init()}
<h:form id="custRoleFeatures" enctype="multipart/form-data">
<div class="a_m_c">
<div class="title">Role Feature Inputs</div>
<div class="p_20">    
<div class="w360 f_l f13 ff_lato c_8 c_8_tf label_w100">
<div id="roledev" style="color:red;"/>
<label>Role Name:</label>
<h:selectOneMenu id="custRoleFeatureId" name="custRoleFeatureId" class="w242" value="# {customerRoleFeature.customerRoleId}" onchange="this.form.submit()">
<f:selectItem itemLabel="Select a name"/>
<f:selectItems value="#{customerRole.getActiveRoleList()}" var="u" itemLabel="#{u.customerName}" itemValue="#{u.customerRoleId}" />       
<f:ajax listener="#{customerRoleFeature.onSelectRole}"/>                                  </h:selectOneMenu>
<div id="ro" style="color:red;"/>
<div class="clear"></div>
<!-- cust_role_feature list START-->
<div class="box_01" style="width:675px;height:220px">
<div class="title">Feature List</div>
<table class="users_list">
<tr class="titles">
<td class="titles p_l_20" style="width:180px;">Feature Name</td>
<td class="titles p_l_20">Create</td>
<td class="titles p_l_20">View</td>    
<td class="titles p_l_20">Update</td>       
<td class="titles n_b_r">Delete</td>        
</tr>
</table>

         - &GT;                #{a.getFeature()。的getName()}
         #{} a.create               #{} a.create     

<ui:fragment rendered = "#{a.view eq 'n'}">
<td class="last_name p_l_20"><input type="checkbox" id="viewId" name="viewId"  value="#{a.getFeature().getFeatureId()}">#{a.create}</input></td>
</ui:fragment>
<ui:fragment rendered = "#{a.view eq 'y'}">
<td class="last_name p_l_20"><input type="checkbox" id="viewId" name="viewId"  value="#{a.getFeature().getFeatureId()}" checked="true">#{a.create}</input></td>
</ui:fragment>

<ui:fragment rendered = "#{a.update eq 'n'}">
<td class="last_name p_l_20"><input type="checkbox" id="updateId" name="updateId"  value="#{a.getFeature().getFeatureId()}" >#{a.update}</input></td>
</ui:fragment>
<ui:fragment rendered = "#{a.update eq 'y'}">
<td class="last_name p_l_20"><input type="checkbox" id="updateId" name="updateId"  value="#{a.getFeature().getFeatureId()}" checked="true">#{a.update}</input></td>
</ui:fragment>
<ui:fragment rendered = "#{a.delete eq 'n'}">
<td class="last_name p_l_20"><input type="checkbox" id="deleteId" name="deleteId"  value="#{a.getFeature().getFeatureId()}" >#{a.delete}</input></td>
</ui:fragment>
<ui:fragment rendered = "#{a.delete eq 'y'}">
<td class="last_name p_l_20"><input type="checkbox" id="deleteId" name="deleteId"  value="#{a.getFeature().getFeatureId()}" checked="true">#{a.delete}</input></td>
</ui:fragment>
</tr>
</ui:repeat>
</table></div>  
</div>
<h:commandButton value="Save" action="#{customerRoleFeature.addCustomerRoleFeature()}" onclick="return checkLikes();" class="bt_st_01 green_btn"/>  
</div>

0 个答案:

没有答案