0
votes

I have the following JSF composite component:

<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>

Assuming the composite is invoked as

<h:form id="form">
    <cc:myComposite id="cc" input="#{bean.input}" 
                    output="#{bean.output}" action="#{bean.action}"  />
</h:form>

Once bean.action is invoked it sets a value in bean.output. I need to access this value in my javascript, something like this

document.getElementById('form:cc:output').value

From myComp I can set the attribute with

getAttributes().put("output", output); 

But the data resides in the backing bean. Any ideas?

1

1 Answers

0
votes

You need a component to submit the 'output' value to the backing bean. Use inputHidden to accomplish this:

<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>

Then you'll be able to set the 'output' value using its hidden input element via javascript.