I came across a weird issue. Here is the situation:
I am using my solution regarding displaying and hiding content based on the screen size: https://xpagesandme.wordpress.com/2015/01/20/diving-into-bootstrap-and-font-awesome-part-3-displaying-hiding-content-based-on-device-type/
So, I set up a custom control, containing the UI for a mobile device. I am using the "rendered" property of said custom control to hide or display it, based on the param value from my post.
Here is the weird issue:
Inside the custom control, I have a button that is supposed to set a scoped variable, do a partial refresh on a panel inside a modal and then display the modal (the call to open the modal is inside the onComplete event of the event handler).
The modal opens, but the scoped variable was not updated.
When I remove the rendered property of the custom control, it works. If I put the rendered property back in again, it doesn't work.
Also, any simple action (i.e. opening a page) won't work. However, CSJS that I put into the onComplete or onStart event of the event handler, will be executed.
Any idea?
P.S.: Here is an example XPage. Remove the rendered property of any of the buttons and the code in the onClick event will work:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view
xmlns:xp="http://www.ibm.com/xsp/core">
<xp:eventHandler
event="onClientLoad"
submit="false">
<xp:this.script><![CDATA[$(window).on('load resize', function(){
var screenWidth = $(window).width();
var sDevice = '';
switch(true){
case (screenWidth < 768):
sDevice = 'mobile';
break;
case (screenWidth < 922):
sDevice = 'tablet';
break;
case (screenWidth >= 922):
sDevice = 'desktop'
}
XSP.partialRefreshGet( '#{id:pnlList}', {params: {'sDevice': sDevice}});
});]]></xp:this.script>
</xp:eventHandler>
<xp:panel
id="pnlList">
<xp:button
value="Button Mobile"
id="button1" rendered="#{javascript:param.sDevice == 'mobile';}">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="pnlToUpdate"
onStart="alert('onStart')"
onComplete="alert('onComplete')">
<xp:this.action><![CDATA[#{javascript:sessionScope.put('sTestValue', 'Button Mobile clicked')}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:br></xp:br>
<xp:button
id="button2" value="Button Tablet" rendered="#{javascript:param.sDevice == 'tablet';}">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="pnlToUpdate"
onStart="alert('onStart')"
onComplete="alert('onComplete')">
<xp:this.action><![CDATA[#{javascript:sessionScope.put('sTestValue', 'Button Tablet clicked')}]]></xp:this.action>
</xp:eventHandler></xp:button>
<xp:br></xp:br>
<xp:button
value="Button Desktop"
id="button3" rendered="#{javascript:param.sDevice == 'desktop';}">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="pnlToUpdate"
onStart="alert('onStart')"
onComplete="alert('onComplete')">
<xp:this.action><![CDATA[#{javascript:sessionScope.put('sTestValue', 'Button Desktop clicked')}]]></xp:this.action>
</xp:eventHandler></xp:button></xp:panel>
<xp:panel id="pnlToUpdate">
<xp:text
escape="true"
id="computedField1" value="#{sessionScope.sTestValue}">
</xp:text></xp:panel></xp:view>