JSF参数传递方式之四:f:attribute标签传递+五:f:setPropertyActionListener 标签传递

JSF参数传递方式之四:f:attribute标签传递

页面到Bean的参数传递
页面中设置参数:
Java代码
  1. <h:form>
  2. <h:commandButtonaction="#{paramBean.test3}"value="Test11"actionListener="#{paramBean.changeName}">
  3. <f:attributename="name"value="hujilie"/>
  4. </h:commandButton>
  5. <h:commandLinkaction="#{paramBean.test3}"value="Test12"actionListener="#{paramBean.changeName}">
  6. <f:attributename="name"value="hujilie"/>
  7. </h:commandLink>
  8. </h:form>
后台取参数:
Java代码
  1. publicvoidchangeName(ActionEvente)
  2. {
  3. UIComponentcomponent=e.getComponent();
  4. Map<String,Object>map=component.getAttributes();
  5. setName((String)map.get("name"));
  6. }

JSF参数传递方式之五:f:setPropertyActionListener 标签传递

页面到Bean的参数传递
页面中设置参数:
Java代码
  1. <h:form>
  2. <h:commandButtonaction="#{paramBean.test3}"value="Test14">
  3. <f:setPropertyActionListenervalue="hujilie"target="#{paramBean.name}"/>
  4. </h:commandButton>
  5. <h:commandLinkaction="#{paramBean.test3}"value="Test15">
  6. <f:setPropertyActionListenervalue="hujilie"target="#{paramBean.name}"/>
  7. </h:commandLink>
  8. </h:form>

你可能感兴趣的:(attribute)