JSF参数传递方式之四:f:attribute标签传递
页面到Bean的参数传递
页面中设置参数:
页面中设置参数:
- <h:form>
- <h:commandButton action="#{paramBean.test3}" value="Test11" actionListener="#{paramBean.changeName}">
- <f:attribute name="name" value="hujilie"/>
- </h:commandButton>
- <h:commandLink action="#{paramBean.test3}" value="Test12" actionListener="#{paramBean.changeName}">
- <f:attribute name="name" value="hujilie"/>
- </h:commandLink>
- </h:form>
<h:form>
<h:commandButton action="#{paramBean.test3}" value="Test11" actionListener="#{paramBean.changeName}">
<f:attribute name="name" value="hujilie"/>
</h:commandButton>
<h:commandLink action="#{paramBean.test3}" value="Test12" actionListener="#{paramBean.changeName}">
<f:attribute name="name" value="hujilie"/>
</h:commandLink>
</h:form>
后台取参数:
- public void changeName(ActionEvent e)
- {
- UIComponent component = e.getComponent();
- Map<String, Object> map = component.getAttributes();
- setName((String)map.get("name"));
- }
JSF参数传递方式之五:f:setPropertyActionListener 标签传递
页面到Bean的参数传递
页面中设置参数:
页面中设置参数:
- <h:form>
- <h:commandButton action="#{paramBean.test3}" value="Test14">
- <f:setPropertyActionListener value="hujilie" target="#{paramBean.name}"/>
- </h:commandButton>
- <h:commandLink action="#{paramBean.test3}" value="Test15">
- <f:setPropertyActionListener value="hujilie" target="#{paramBean.name}"/>
- </h:commandLink>
- </h:form>