posts - 5,  comments - 7,  trackbacks - 0
第一种方法:
JSF页面中的代码:
<h:form id="messageForm">
<h:outputText id="outputMessage"/>
<h:commandButton value="Get Message"
actionListener
="#{testForm.sendMessage}"/>
</h:form>
后台程序:
public void sendMessage(ActionEvent e)
{
FacesContext context 
= FacesContext.getCurrentInstance();
UIViewRoot view 
= context.getViewRoot();
HtmlOutputText output 
=
(HtmlOutputText)view.findComponent(
"messageForm:outputMessage");
output.setStyle(
"color:blue");
output.setValue(
"Who's the Mann?");
}
之后,当点击Get Message的时候页面就会在outputMessage的地方输出 Who's the Mann?
第二种方法:
<h:inputText value="#{registrationForm.comments}"
binding
="#{registrationForm.commentsInput}"/>
commentsInput是RegistrationForm中的一个HtmlInputText类型的一个变量,通过binding属性将前台UI控件和后台同类型的变量绑定,就可以在后台直接操作了。
posted on 2008-11-23 00:38 Vincent-chen 阅读(165) 评论(0)  编辑  收藏 所属分类: JSF

只有注册用户登录后才能发表评论。


网站导航: