This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 5, 2013, 2:37 PM
11 Posts

djDateTextBox onChange event set a requestScope

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: djDateTextBox
  • Replies: 3

All, why am I getting ReferenceError: requestScope is not defined error when I am trying to set a requestScope variable onChange event? I was able to set selected value to a display field but not able to set it to any scoped variable, below is my code, can you please help me?

<xe:djDateTextBox id="LDate" value="#{requestData.LDate}">
            <xp:eventHandler event="onChange" submit="false" refreshMode="complete"
                refreshId="TTP">
                <xe:this.script><![CDATA[     

                  var sDate = XSP.getElementById("#{id:LDate}").value;           


                    XSP.getElementById("#{id:totalDays}").value = sDate;
                    requestScope.put("selDate", sDate);
    ]]></xe:this.script>
            </xp:eventHandler>

</xe:djDateTextBox>

 

Aug 5, 2013, 5:15 PM
586 Posts
Client vs. Server

It's undefined because you're working in Client Side JS and "requestScope.put" is Server Side JavaScript.

Remember when working with the browser DOM and the XSP object that's all client side stuff.  

I'm not 100% sure what you're doing here..  looks like you're getting the value of this field (LDate)... then you're trying to use CSJS put that value into a field called "totalDays" and also put that value into a requestScope of "selDate".  So I don't know what the goal is... but I'd move all this to SSJS myself...  you can't use XSP then but can do getComponent....

Remember requestScope has a very short life span...  I rarely use it myself...  I use viewScope a lot more so the value sticks around for the life of the page.

 

Hope that helps

Aug 5, 2013, 8:27 PM
11 Posts
djDateTextBox onChange event set a requestScope

David,

Thank you so much for the clarification on the requestScope. I have 2 date fields one is start date and the other is end date, when I select start date , I want to use start date value for the min constraints for the End Date dojo attributes:

Start Date :

<xe:djDateTextBox id="LDate" value="#{requestData.LDate}">
            <xp:eventHandler event="onChange" submit="false" refreshMode="complete"
                refreshId="TTP">
                <xe:this.script><![CDATA[                    
                  **** I want to store value here so that I can access it in the EndDate ( use this value for min constraints for the EndDate )*****
    ]]></xe:this.script>
            </xp:eventHandler>
            <xp:this.dojoAttributes>
                <xp:dojoAttribute name="constraints">
                    <xp:this.value><![CDATA[#{javascript:
                        function pad(n){return n<10 ? '0'+n : n}
                        var date1 = @Today();                        
                        var year = @Year(date1);
                        var month = @Month(date1);
                        var day = @Day(date1);
                        var min = "min:'" + year + "-" + pad(month) + "-" + pad(day) + "'";
                        return "{" + min + "}";
                    }]]></xp:this.value>
                </xp:dojoAttribute>
            </xp:this.dojoAttributes>
        </xe:djDateTextBox>

 

End Date:

<xe:djDateTextBox id="rDate" value="#{requestData.RDate}">
            <xp:this.dojoAttributes>
                <xp:dojoAttribute name="constraints">
                    <xp:this.value><![CDATA[#{javascript:
                        function pad(n){return n<10 ? '0'+n : n}
                       var startDateID = "#{id:LDate}";                     
                        var date1 = new Date (I want to get the LDate field value here but I am not able to get it. I was trying to store value in a scoped variable in onchange event of the Ldate Field )
                        var year = @Year(date1);
                        var month = @Month(date1);
                        var day = @Day(date1);
                        var min = "min:'" + year + "-" + pad(month) + "-" + pad(day) + "'";
                        return "{" + min + "}";
                    }]]></xp:this.value>
                </xp:dojoAttribute>
            </xp:this.dojoAttributes>

        </xe:djDateTextBox>


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal