Bitwyse1
Bitwyse1

Reputation: 339

xPages throwing error on code in this.rendered

I have an xPages application that uses the one ui application layout. I have a custom control with a navigator and several different tree nodes.

I have some code to render or not based on a value from one of my beans. It works great for my basic leaf node but when I use the same code in a basic container node I get an error saying that aPropertyProfile is null. The bean is loaded just fine in the parent xPage and the rendered code of the basic leaf node works fine. I suspect this has to do with csjs vs. ssjs but when adding the computed render code for the basic container node it says Javascript ( ServerSide ).

Any thoughts why this isn't working?

<xe:basicContainerNode label="Register for e-Statements" submitValue="RegisterForEstatements" enabled="true">
    <xe:this.rendered><![CDATA[#{javascript:if( aPropertyProfile.getStatementCoupon_1().equalsIgnoreCase( "Statements" ) )
       return true;
    else
        return false;}]]>
    </xe:this.rendered>
</xe:basicContainerNode>

<xe:basicLeafNode label="Register for e-Statements" onClick="linkToEstatementsSignup();">
   <xe:this.rendered><![CDATA[#{javascript:
         if( aPropertyProfile.getStatementCoupon_1().equalsIgnoreCase( "Statements" ) )
              return true;
         else
              return false;
   }]]></xe:this.rendered>
</xe:basicLeafNode>

Upvotes: 0

Views: 164

Answers (1)

stwissel
stwissel

Reputation: 20384

What works for me is isolating my beans in a SSJS wrapper, it might work for you too. So you would write:

<xe:basicContainerNode label="Register for e-Statements" submitValue="RegisterForEstatements" enabled="true">
    <xe:this.rendered><![CDATA[#{javascript:myDisplay.renderStatements()}]]>
    </xe:this.rendered>
</xe:basicContainerNode>

and in a SSJS library you add:

 var myDisplay = {
     /* Show the e-statement node */
     "renderStatements" : function() {
              var result = false;
              try {
                  result = aPropertyProfile.getStatementCoupon_1().equalsIgnoreCase( "Statements" );
              } catch (e) {
                  print(e.message);
              }
              return result;
      },

     /*Do other stuff */
     "renderAdvanced" : function() {

     }
 }

Using this approach you have clean XPages source and can add better error handling to the calls. It also could sort out what looks like a timing issue.

Upvotes: 1

Related Questions