I have a flow.xml file t开发者_运维技巧hat's calling a method on a bean. I just want to have a string that I get from a textbox passed in as a parameter to the method. I've added a h:inputText to my xhtml page, but I can't get it to set a String variable in the corresponding flow. What is the simplest possible way I can get a value from a textbox into a flowscope String variable?
public class SomeBean{
String val;
//getters & setters
public String foo(){
System.out.println(val);
return "SUCCESS";
}
}
xhtml
<h:form>
<h:inputtext value="#{someBean.val}"/>
<h:commandButton action="#{someBean.foo}"/>
</h:form>
as html it will render a html form with a textbox and a submit button on licking button it will call foo()
and text from txtbox will get binded to val
MyBean myBean = (MyBean) facesContext.getApplication().createValueBinding("#{flowScope.myBean}").getValue(facesContext);
String val = myBean.GetBeanProperty();
Here you should more examples.
精彩评论