This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.

May 7, 2013, 7: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">
                 javascript:var tempstatus = getComponent("Status").getValue();
                tempstatus != "Final"}]]>
        <xp:eventHandler event="onclick" submit="true" refreshMode="complete" immediate="false" save="true" id="SaveAsDraft">
                var url="web.nsf" + "/xThankYouDraft.xsp";
May 7, 2013, 8:55 PM
110 Posts
Re: Hide when
 Compute this into the 'Visible' property of the button:

May 8, 2013, 10:34 AM
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 8, 2013, 9:35 PM
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, 2: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. New discussions are now taking place in the IBM Developer Answers forum.