h:commandButton

 

h:commandButton提交表单,传递参数并跳转到另一个页面

关键字: jsf问题

xml代码:

<h:commandButton id="editbutton" action="edit" image="/images/EDIT.jpg" actionListener="#  {search.edit}">
    <f:attribute name="ehrid" value="#{result.ehr_id}"/>
</h:commandButton>

页面跳转通过faces-config.xml文件来实现:

<navigation-rule>
     <from-view-id>/pages/personalinfoselect.xhtml</from-view-id>
       <navigation-case>
         <from-outcome>edit</from-outcome>
         <to-view-id>/pages/personalinfoedit.xhtml</to-view-id>
       </navigation-case>
</navigation-rule>

参数传递actionListener事件来实现,后台代码:

 public void edit(ActionEvent event){
        String ehruser = (String) event.getComponent().getAttributes().get("ehrid");
        System.out.println("ehrusermap="+ehruser);
}

原文地址:https://www.cnblogs.com/Catherinezhilin/p/9909783.html