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



May 7, 2013, 11:09 PM
90 Posts

Hide when

  • Category: Other
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 4
 
I want this button to "hide when" if *either* of the following two things are true:

if the status is Final, or, if the document is in read mode (i.e. not in edit mode).

I still don't really grok yet how that, which was straightforward in Notes, is done in xPages now.   Any help appreciated.

<xp:button value="Save As Draft" id="SubmitDraft" styleClass="buttonred">
        <xp:this.rendered><![CDATA[#{
                 javascript:var tempstatus = getComponent("Status").getValue();
                tempstatus != "Final"}]]>
                 </xp:this.rendered>
        <xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true" id="SaveAsDraft">
            <xp:this.action>
                <![CDATA[#{javascript:
                Submission.replaceItemValue("Status","Draft");
                Submission.save();
                var url="web.nsf" + "/xThankYouDraft.xsp";
                context.redirectToPage(url);
}]]> 
May 8, 2013, 12:55 AM
110 Posts
Re: Hide when
 Compute this into the 'Visible' property of the button:


Submission.getItemValueString('Status')!='Final'||Submission.isEditable() 
May 8, 2013, 2:34 PM
90 Posts
Re: Hide when
Thanks Baxter, that got me thinking. I modified a bit what you suggested, as ... if the document was not in edit mode -- then that needed to override the status check, rather than be equal to it as an OR.

 here's my hidewhen that is working. if doc isn't in edit mode, then don't render this element visible. if it is in edit mode, and the status field is not set to final, then do render this element visible. Otherwise, don't render it visible.

Probably really wordy coding, but it's working, for the sake of others who are desperate:

        var show = "";
        if (!Submission.isEditable()) {show = "No"}
        else if (Submission.getItemValueString('Status')!='Final') { show = "Yes"}
        show == "Yes";  
May 9, 2013, 1:35 AM
453 Posts
Re: Hide when
Understand that the Visible property is not the same as the Notes Hide-When. The Visible property actually controls if a control is even rendered. Setting the Visible to False stops the control value from even being present on the XPage. I can't say how long I fought with this until I realised what was happening. If you want the control hidden but it's value available then you need to set the Style="display:none". The display:none functions more like the Hide-When than the Visible does.  I use the style="display:none" almost as much as I use the visible property. If you notice if you enter a formula into the visible property, the formula appears on the All Properties under the Render property. I think this is a bit of unfortunate naming. I think the Visible property should be called Rendered so it is consistent. To me the visible property would be better to set the display:none in the style.

Would have saved me several hours of experimenting until I finally got that straight. 
May 9, 2013, 6:06 PM
366 Posts
Re: Hide when
Some more information.


Via SSJS, if the "Loaded" property is true and the "Rendered" property is false then the value stored in the component is still available programmatically as it is loaded in the component tree but not displayed.


From CSJS the values are ONLY available in document "Edit" mode. 


 

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