Jsf 如何从支持bean返回值作为复合组件属性
我有以下JSF复合组件:Jsf 如何从支持bean返回值作为复合组件属性,jsf,composite-component,Jsf,Composite Component,我有以下JSF复合组件: <composite:interface componentType="myComp"> <composite:attribute name="input" type="java.lang.Integer" /> <composite:attribute name="output" type="java.lang.Integer" /> <composite:attribute name="action"
<composite:interface componentType="myComp">
<composite:attribute name="input" type="java.lang.Integer" />
<composite:attribute name="output" type="java.lang.Integer" />
<composite:attribute name="action" method-signature="java.lang.String action()"/>
</composite:interface>
<composite:implementation>
<h:inputText id="input" value="#{cc.attrs.input}" />
</composite:implementation>
从mycop中,我可以使用
getAttributes().put("output", output);
但是数据驻留在支持bean中。有什么想法吗?您需要一个组件将“输出”值提交给支持bean。使用INPUTHIDEN完成以下任务:
<composite:interface componentType="myComp">
<composite:attribute name="input" type="java.lang.Integer" />
<composite:attribute name="output" type="java.lang.Integer" />
<composite:attribute name="action" method-signature="java.lang.String action()"/>
</composite:interface>
<composite:implementation>
<h:inputText id="input" value="#{cc.attrs.input}" />
<h:inputHidden id="output" value="#{cc.attrs.output}" />
</composite:implementation>
然后,您就可以通过javascript使用其隐藏的输入元素设置“output”值。您的意思是通过javascript设置输出属性还是检索它?我在寻找后者,类似于var x=document.getElementById'form:cc:output'.value;
getAttributes().put("output", output);
<composite:interface componentType="myComp">
<composite:attribute name="input" type="java.lang.Integer" />
<composite:attribute name="output" type="java.lang.Integer" />
<composite:attribute name="action" method-signature="java.lang.String action()"/>
</composite:interface>
<composite:implementation>
<h:inputText id="input" value="#{cc.attrs.input}" />
<h:inputHidden id="output" value="#{cc.attrs.output}" />
</composite:implementation>