3 Replies Latest reply: Apr 26, 2012 9:05 AM by 933202 RSS

    Can jsf tag values be modified by javascript?

    308675
      I have a jsf tag in a web page:
      <h:outputText id="outputTextTest" value="someValue" />
      I would like to modify the value of this tag with javascript for instance:
      document.getElementById('outputTextTest').value = "new value";
      is there a way to do this?
        • 1. Re: Can jsf tag values be modified by javascript?
          308675
          The answer is yes, they can, but you have to use the right id to grab the component. If the component is in a form, you may have to attach the form id to the component id to grab the component
          document.getElementById('mainForm:formid:elementid').value = 'new value';
          • 2. Re: Can jsf tag values be modified by javascript?
            gimbal2
            Atlas77 wrote:
            The answer is yes, they can, but you have to use the right id to grab the component. If the component is in a form, you may have to attach the form id to the component id to grab the component
            document.getElementById('mainForm:formid:elementid').value = 'new value';
            That changes the client side state, but not the server side state. You can try to manually intervene using javascript, but likely you are just going to create misery for yourself. Do it the JSF way, or don't do it.
            • 3. Re: Can jsf tag values be modified by javascript?
              933202
              I am having the same problem, here what i am doing is there is multiselectdropdowncheck box where user can select multiple options, and these options will be displayed in the box.
              I am able to send the form values to javascript and setting the style.display is none for multiselectdropdowncheckbox (i mean collapsing the box) ,when it is expanded. But this value is not retaining in page.

              For code and all please see my thread.

              problem in multiselectcheckdropdownbox.

              Please help me out. help would be greatly appreciated.

              Thanks
              Venkat