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

xiaoxiao2026-08-30  27

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

参数正常获得。

相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-5052112.html

最新回复(0)