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



Apr 12, 2011, 7:33 AM
261 Posts

Re: Order of Execution - Partial update or Code

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: xpages,Xpage
  • Replies: 3
The SSJS code in the button is executed first. After that the partial updated is executed, reflecting any changes that are the result of the SSJS code.
 
Mark
Apr 13, 2011, 11:08 AM
38 Posts
Re: Order of Execution - Partial update or Code
Thnaks for replying.
 
Now let me come to the root cause because of which I was forced to ask this question.
 
I have a XPage in which a panel is there. Inside the panel there is an edit box and button. On click of button I get the value in the edit box (via SSJS code) and partial refresh the panel so that it gets hidden due to a condition. But I am not anble to get the value of edit box on the click of button. But if I remove the partial refresh and then click then I get the value. With this I was thinking that the page gets first partially refreshed and then it executes SSJS code.
 
Here is the complete code for the XPage 
 

<?xml version="1.0" encoding="UTF-8"?>

<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

<xp:inputText id="showHidePanel" defaultValue="1"></xp:inputText>

<xp:panel id="outerPanel">

<xp:panel id="innerPanel">

<xp:this.rendered><![CDATA[#{javascript:getComponent("showHidePanel").getValue() == "1";}]]></xp:this.rendered>

<xp:inputText id="inputText1"></xp:inputText>&#160;

<xp:button value="Print Value" id="button1">

<xp:eventHandler event="onclick" submit="true"

refreshMode="partial" refreshId="showHidePanel">

<xp:this.action><![CDATA[#{javascript:print("--> " + getComponent("inputText1").getValue())}]]></xp:this.action>

<xp:this.script><![CDATA[document.getElementById("#{id:showHidePanel}").value = "0";]]></xp:this.script>

</xp:eventHandler>

</xp:button>

</xp:panel>

</xp:panel>

</xp:view>

 
Can you tell me how can I get the value in edit box using partial refresh? 
 
Apr 13, 2011, 12:09 PM
40 Posts
Re: Order of Execution - Partial update or Code
Based on your code,  your button is partial refreshing showHidePanel which is the inputText field ... your refresh needs to include both the inputText field and the panel you want to show or hide based on your rendered property.  When you click the button, a partial refresh is executed and the form that contains the element you are partially refreshing is submitted to the server ... the life cycle is then processed, and during the invoke application phase your button code is executed, at this point, all data is assumed valid, and has been applied to the data model ... after that, the renderResponse phase executes, and the html generated for the id you specify for partial Refresh is sent back to and applied to the HTML in the document ...
 
All that being said, you are actually making this harder than it needs to be ... first bind showHidePanel to a viewScoped variable... such as viewScope.showHidePanel (add the attribute value="#{viewScope.showHidePanel}" to the xp:inputText tag) ... then move the inputText component inside outerPanel. Change the rendered property of the innerPanel to #{javascript:viewScope.get("showHidePanel") == "1"} then set the refreshId of the button's eventHandler to outerPanel ....it'll work then...
 
 Like this:
 

<?xml version="1.0" encoding="UTF-8"?>

<xp:view xmlns:xp="http://www.ibm.com/xsp/core">

<xp:panel id="outerPanel">

<xp:inputText id="showHidePanel" defaultValue="1" value="#{viewScope.showHidePanel}"></xp:inputText> 

<xp:panel id="innerPanel">

<xp:this.rendered><![CDATA[#{javascript:viewScope.get("showHidePanel") == "1";}]]></xp:this.rendered>

<xp:inputText id="inputText1"></xp:inputText>&#160;

<xp:button value="Print Value" id="button1">

<xp:eventHandler event="onclick" submit="true"

refreshMode="partial" refreshId="outerPanel">

</xp:eventHandler>

</xp:button>

</xp:panel>

</xp:panel>

</xp:view>

 
Can you tell me how can I get the value in edit box using partial refresh? | 
 


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