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



Feb 22, 2012, 2:48 PM
8 Posts
topic has been resolvedResolved

Problem submitting an area of page

  • Category: Server Side JavaScript
  • Platform: Not Applicable
  • Release: 8.5.2
  • Role: Developer
  • Tags: partial refresh
  • Replies: 4
Hi,
 
 I'm trying to do a partial refresh when clicking on links. The links are within a Repeat to generate their labels dynamically. The repeat is fed by data from a JSON object. Just to have the bare minimum I created this XPage:
 
 Generate the JSON object (myJSONcategories) in the beforePageLoad event:
 
    <xp:this.beforePageLoad><![CDATA[#{javascript:
        txt = "myJSONCategories = [{'category' : 'a'},{'category' : 'b'},{'category' : 'c'}]";
        var myJSONcategories = eval(txt);}]]>
    </xp:this.beforePageLoad>

    <xp:panel id="panel1">

Create the Repeat control bound to the myJSONcategories:
        <xp:repeat
            id="repeat1"
            rows="30"
            var="category"
            value="#{javascript: return myJSONcategories;}">
 
Create the Link, set the Label to the category name. All that the Link does is to set a viewScope variable (to blank in test), and the 'panel1' Panel should be refreshed.
            <xp:link
                escape="true"
                text="#{category.category}"
                id="link1">

                <xp:eventHandler
                    event="onclick"
                    submit="true"
                    refreshMode="partial"
                    refreshId="panel1">
                    <xp:this.action><![CDATA[#{javascript:viewScope.selectedPeriod = "";}]]></xp:this.action>
                </xp:eventHandler>
            </xp:link><xp:br></xp:br>
        </xp:repeat>
    </xp:panel>
 
 
The links are displayed correctly after the page is loaded. Clicking any of the links results in the following error message:
 
"Problem submitting an area of page. Unable to load /URL/Test.nsf$$ajaxmode=full&$$ajaxid=view%3A_id%3Apanel1 status 500"
 
Any idea why is it happening?
 
Thank you in advance,
 
Etyien
 
Feb 22, 2012, 9:27 PM
272 Posts
Re: Problem submitting an area of page
Hi,
 
The repeatControl uses the a SSJS variable (myJSONcategories) defined in beforePageLoad.
SSJS variables defined in beforePageLoad are not available anymore during a partial refresh.
 
Hope this helps
Sven
 
Feb 23, 2012, 9:55 AM
8 Posts
Re: Problem submitting an area of page
Hi Sven,
 
Thanks for your reply. I moved the code from beforePageLoad under a computed field within the panel that I'm trying to refresh. So the code now looks like this:
 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:panel id="panel1">
      <xp:text escape="true" id="computedField1">
        <xp:this.value><![CDATA[#{javascript:
             txt = "myJSONCategories = [{'category' : 'a'},{'category' : 'b'},{'category' : 'c'}]";
             var myJSONcategories = eval(txt);
             return myJSONcategories;}]]>
         </xp:this.value>
       </xp:text>
       <xp:br></xp:br>
       <xp:repeat id="repeat1" rows="30" var="category" value="#{javascript: return myJSONcategories;}">
            <xp:link escape="true" text="#{category.category}" id="link1">
                <xp:eventHandler
                    event="onclick"
                    submit="true"
                    refreshMode="partial"
                    refreshId="panel1">
                    <xp:this.action><![CDATA[#{javascript:viewScope.selectedPeriod = "";}]]></xp:this.action>
                </xp:eventHandler>
            </xp:link><xp:br></xp:br>
        </xp:repeat>
    </xp:panel>
</xp:view>
 
It didn't work this way either. Then I moved the computed field outside the panel but nothing changed. Still no luck...
Thanks,
 
Etyien
Feb 23, 2012, 11:28 AM
272 Posts
Re: Problem submitting an area of page
Hi again,
 
the problem is that recalculation of the values are not running correctly: The values of the repeat control are calculated two times during the refresh ( in JSF Phase 1 and 6 ), and the values from the computed field are only recalculated once in JSF phase 6. The SSJS variable is not available during Phase 1, that's why it fails.
 
You can use dataContext-Variables to fix this:
 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:panel id="panel1">

        <xp:this.dataContexts>
            <xp:dataContext var="data">
                <xp:this.value><![CDATA[#{javascript:txt = "myJSONCategories = [{'category' : 'a'},{'category' : 'b'},{'category' : 'c'}]";
             var myJSONcategories = eval(txt);
             return myJSONcategories;}]]></xp:this.value>
            </xp:dataContext>
        </xp:this.dataContexts>

        <xp:br></xp:br>
        <xp:repeat id="repeat1" rows="30" var="category"
            value="#{javascript: return data;}">
            <xp:link escape="true" text="#{category.category}"
                id="link1">
                <xp:eventHandler event="onclick" submit="true"
                    refreshMode="partial" refreshId="panel1">
                    <xp:this.action><![CDATA[#{javascript:viewScope.selectedPeriod = "";}]]></xp:this.action>
                </xp:eventHandler>
            </xp:link>
            <xp:br></xp:br>
        </xp:repeat>
    </xp:panel>
</xp:view>
 
Sven
 
Feb 23, 2012, 2:06 PM
8 Posts
Re: Problem submitting an area of page
Thanks a lot, Sven!

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