Catherine_zhilin

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

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);
}

 

posted on 2018-11-05 16:24  kkkshiki  阅读(418)  评论(0)    收藏  举报