FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Sep 14, 2013, 4:17 PM
453 Posts

Hiding Controls

  • Category: Performance
  • Platform: All
  • Release: 9.0
  • Role: Developer
  • Tags: rendered loaded
  • Replies: 4

I have a panel on an XPage that contains a fair number of controls that I need access to but I need them 'hidden'.

I am using a style formula that is set to display:none. This works fine but I suspect is not the quickest way to do this. I read somewhere to set rendered to false and loaded to true, tried that and the page loads a fair bit quicker but it would appear that the defaults for some of the controls are not computed during this process so the XPage does not respond correctly.

My question is there a better way to "hide" the panel than display:none?

Sep 15, 2013, 9:29 AM
366 Posts
That is how it's supposed to work

This is just sample code demonstrating that.

 

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

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

 

<xp:button value="populate field" id="button1">

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

refreshMode="complete">

<xp:this.action><![CDATA[#{javascript:var t1 = getComponent("inputText1").getValue();

getComponent("computedField1").setValue(t1);}]]></xp:this.action>

</xp:eventHandler></xp:button>

<xp:br></xp:br>

<xp:br></xp:br>

<xp:br></xp:br>

<xp:inputText id="inputText1" rendered="false" loaded="true" defaultValue="Paul T. Calhoun"></xp:inputText>

<xp:br></xp:br>

<xp:br></xp:br>

<xp:text escape="true" id="computedField1"></xp:text></xp:view>

 

When/Where are you trying to read the default values ?  Where on the XPage are they?  

 

Sep 17, 2013, 8:06 AM
589 Posts
hmmm

I normally defer to Paul but I'm not sure I understand his sample code.

Before Paul's post my understanding is that if something is not rendered then it didn't exist for the most part.  So no default values, no logic,  you're just not able to use it.  Bill is getting around this by doing display: none; but I don't really like that as it's not real security and fairly easy to manipulate with browser development tools.

So what I would do is control the rendered property of whatever the UI controls are.  But I think I would normally just bind those controls to viewScope variables, or these days some kind of bean.  So the controls in effect become display only.  The "real" controls and logic are now in memory so I can still set and use them as I would want.  Best of both worlds and what I would suggest is best practice... 

Until Paul's snippet...  :-)

That seems to suggest that loaded=true makes something available where rendered=false?  First I've heard of that...  so I guess I'll need to play with that sometime.

Sep 17, 2013, 12:23 PM
453 Posts
My display:none is not for security reasons..

the values that are hidden I just want out of the way. Many of them under normal conditions I do not render, but there are a  number that I need to have access to programatically and also need some of the control to load the default and format. something similar to HTML type=hidden thing we would do in a web form in N/D.

Sep 18, 2018, 8:53 PM
1 Posts
Seeing similar behavior as Bill too

Paul (and David), I too had a requirement where I needed a field's default value (the field's id="inp_Type" and the field's name = "Type" as shown below) to be made available on the form at the time of submitting, -BUT- I didn't want it to be visible in the UI (also the reason why I didn't code for a label) .

I tried using the 'loaded="true"; attribute of the <xp:inputText> control while not making the field "visible" as suggested, but my managed bean wasn't seeing it.

The below snippet shows the last 2 fields (from a total of 7 UI fields being used) appearing just before my 'Submit' button. The 'Submit' action is nothing more than a call to my JAVA save() method used by my bean, i.e. --> person.save(). This  is from my UI that ultimately creates a Person document within the NAB.

In order for the newly created Person doc to be visible in the NAB's hidden '($Users) lookup view,  the doc needs (among other fields being present) the field named 'Type' to be set to a value of 'Person'.

When I made my 'Type' field control 'visible', the bean sees the value and it gets pushed onto the Person document that I'm in the process of creating within the NAB. However, if I make it NOT visible, through use of the Edit Box attributes, it doesn't get picked up.

I ended up doing the same hack as Bill did (unless he discovered a different way since his last post). I hard-coded a style of  "display:none" to the edit box and allowed the Edit box to be 'visible' to the form' design and bean, but not visible in the UI.

This is being used in a 'New User Registration' UI modal dialog using a managed bean. This is running on Domino 9.0.1FP9 on top of Windows 2012 R2 Standard server with the XPage design using Bootstrap v3.3.7, jQuery v3.2.1, Font Awesome v4.6.3 and Bootswatch v3.3.7.

<div

  class="form-group">

  <xp:label

        id="lbl_ConfirmPasswordTX"

        for="lbl_ConfirmPasswordTX"

        value="Re-enter your Password:" />

  <xp:br></xp:br>

  <xp:inputText

        id="inp_ConfirmPasswordTX"

        password="true" />

    <xp:br></xp:br>

    <xp:inputText style="display:none"

        id="inp_Type"

        value="#{person.Type}"

        defaultValue="Person" 

        loaded="true"/>

  </div>


FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.