JSF参数传递方式之四:f:attribute标签传递
页面到Bean的参数传递
页面中设置参数:
页面中设置参数:
- <h:form>
- <h:commandButtonaction="#{paramBean.test3}"value="Test11"actionListener="#{paramBean.changeName}">
- <f:attributename="name"value="hujilie"/>
- </h:commandButton>
- <h:commandLinkaction="#{paramBean.test3}"value="Test12"actionListener="#{paramBean.changeName}">
- <f:attributename="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> 后台取参数:
- publicvoidchangeName(ActionEvente)
- {
- UIComponentcomponent=e.getComponent();
- Map<String,Object>map=component.getAttributes();
- setName((String)map.get("name"));
- }
JSF参数传递方式之五:f:setPropertyActionListener 标签传递
页面到Bean的参数传递
页面中设置参数:
页面中设置参数:
- <h:form>
- <h:commandButtonaction="#{paramBean.test3}"value="Test14">
- <f:setPropertyActionListenervalue="hujilie"target="#{paramBean.name}"/>
- </h:commandButton>
- <h:commandLinkaction="#{paramBean.test3}"value="Test15">
- <f:setPropertyActionListenervalue="hujilie"target="#{paramBean.name}"/>
- </h:commandLink>
- </h:form>
本文详细介绍了JSF中两种参数传递方法:使用f:attribute标签和f:setPropertyActionListener标签来实现页面到Bean的参数传递。通过具体示例展示了如何在前端设置参数,并在后端获取这些参数。
330

被折叠的 条评论
为什么被折叠?



