I have an xpage in which I added a button. The button has an Action Group and other actions following.
For some reason, the event is firing on page load. I do not have any page load events. The button is a core control, not the dojo button.
<xp:button id="button1" value="Approve Receiving Sheet"
style="font-family:Arial;font-size:9pt;font-style:italic;width:180.0px"
styleClass="button1">
<xp:eventHandler event="onclick" submit="true" refreshMode="complete"
immediate="false" save="true"><xp:this.action><xp:actionGroup>
<xp:this.condition>
<![CDATA[#{javascript:var lookup = document1.getDocument().getUniversalID()
var checkInvoices:string
checkInvoices = @DbLookup("", "(Invoices by RS UNID)", lookup, 2)
var returnValue = @If(@Implode(checkInvoices) == "", false, true)
if(returnValue == false)
{
var x="alert('msg to user');"
view.postScript(x)
return false
}
return true}]]></xp:this.condition><xp:confirm>
Other actions follow conditional action. Changing button from button to submit doesn’t do anything. The postscript message was showing up for true or false, which is why I moved it into an if statement. Thanks in advance, Steve
EDIT: My first answer was not correct! Here is the second one:
The condition will be calculated as soon as one of the actions in the actionGroup are invoked. This means that as long as there is “nothing to do”, your condition will not be executed.
But you have added a confirmation action: This type of action generates a CSJS code block, and checks the condition of the action group before it gets rendered (aka send to the browser). That’s why your CSJS alert is executed.
P.S.
If you are clicking the action multiple times and set the condition to false, the confirmation message will apear anyway. This seems to be a bug.