2

I have the following component:

<p:inputText id="comp1" value="#{xyz.abc}" />

I have another component

<p:inputText id="comp2" value="" />

In the value of comp2... how do I set its value to read it from comp1

I dont want to write the value of comp2 to be >> value="#{xyz.abc}" I just want comp2 to copy the value of comp1

Thanks in advance.

  • 1
    One question: why? Please describe the usecase in a non-technical way. Might be that you try to solve something that is wrong from the beginning – Kukeltje May 17 '15 at 10:39
  • http://stackoverflow.com/questions/30286107/jsf-composite-component-value-and-cif – user1201957 May 17 '15 at 12:38
  • 1
    What do you mean by posting this link? – Kukeltje May 17 '15 at 15:37
  • 1
    The right way depends on the concrete functional requirement. Unfortunately, you're not terribly clear about the concrete functional requirement for which you thought that this would be the right solution. What exactly do those values represent and why exactly would you have a copy and does it need to be readonly or what? Etc. – BalusC May 17 '15 at 18:49
  • Hi guys, Balus Sorry I was new here so did not know how to use it efficiently: To answer you why I need to do this, here is the problem http://stackoverflow.com/questions/30412962/cif-and-rendered-is-not-working-at-all – user1201957 May 23 '15 at 13:02

1 Answers1

0

I would recommend using JavaScript for this:

<p:inputText id="comp1" value="#{xyz.abc}" onkeyup="document.getElementById('comp2').value=this.value;" />

I haven't tested this approach yet but maybe this works for your problem. Of course you can also use another event to bind the JavaScript function at. Have a look at the PrimeFaces docs to find all of them.

LarsBauer
  • 1,539
  • 18
  • 23