4 Replies Latest reply: Feb 14, 2013 10:03 AM by Nooruddin Shaik RSS

    Assign Bean value in script..?

    VISHNU_95
      Hi All,


      How to set bean property value after validation in java script function..?


      for example,
      <script>
      var propertyValue = "";
      dsp:input bean="Profile.value.login" value="propertyValue"
      </script>

      Thanks,
      Vishnu
        • 1. Re: Assign Bean value in script..?
          RMishra
          Hi All,
          How to set bean property value after validation in java script function..?
          for example,
          <script>
          var propertyValue = "";
          dsp:input bean="Profile.value.login" value="propertyValue"
          </script>

          Thanks,
          Vishnu>
          Try this and please let us know whether it works or not:
          <dsp:getvalueof var="abc" bean="/atg/userprofiling/Profile.value.login"/>
          <script>
               var propertyValue = ${abc};
                 // your code here.........
          </script>
          -RMishra

          Edited by: RMishra on Feb 14, 2013 8:26 PM
          • 2. Re: Assign Bean value in script..?
            VISHNU_95
            Hi Mishra,


            My requirement just reverse.. that is ,
            <dsp:form>
            <input type="text" id="idName" value="" />
            <dsp:input type="submit" value="SubmitName" id="submitId" onclick="functionName()">
            </dsp:form>

            Now,

            <script>
            functionName(){
            var varName = document.getElementById('idName').value;
            ..
            after some Validation , i should able set this variable value to dsp:bean property..
            }
            </script>



            Thanks,
            Vishnu
            • 3. Re: Assign Bean value in script..?
              Samdani Gulam
              as RMishra mentioned try to use Expression Language,
              what did you tried ? let us know and what errors you are getting ?
              • 4. Re: Assign Bean value in script..?
                Nooruddin Shaik
                Java script is executed at client side and there will not be any reference to atg bean objects there.

                The bean objects gets translated to html tags at client side, so you can code in regular html tags.

                var name = document.getElementById('idName').value;
                //do validations
                document.getElementById('idName').value="abc"

                When you submit the form, this new value will be set in the bean property.

                Peace
                Shaik