I don't see why h:panelGroup would be any different, but I nevertheless tried it.

<h:panelGroup rendered="false">
   <h:outputText value="#{backingBean.someGetterMethod}" />
</h:panelGroup>

/**
* Getter method in backing bean.  Only ever called from h:outputText.
*/
public String getSomeGetterMethod() {
 logger.debug("Getter method called");
 return "foo";
}


One lame way I found to get around this is by binding the outer component to my 
backing bean and checking the isRendered() property in my getter method:

<h:panelGroup rendered="false" binding="#{backingBean.thePanelGroup}">
   <h:outputText value="#{backingBean.someGetterMethod}" />
</h:panelGroup>

/**
* Getter method in backing bean.  Only ever called from h:outputText.
*/
public String getSomeGetterMethod() {
 logger.debug("Getter method called");
 if (this.pg.isRendered())
 {
   //Do some expensive call to get result.
 }
 return "foo";
}

private UIComponent pg;

public void setThePanelGroup(UIComponent pg) {
 this.pg = pg;
}

public UIComponent getThePanelGroup() {
 return this.pg;
}


That's a considerable amount of code just to prevent a method from being called. I can't find anything in the spec that would prohibit an implementation from guarding against these unnecessary calls. If the component is not to be rendered, what use is it to invoke ValueBinding.setValue()? You of course still need to keep the ValueBinding in the component tree, but there is no reason to actually setValue() when the resultant value is just going to be thrown away.
Does anyone else see the value in this?  Or see something in the spec that would prohibit 
MyFaces from changing their impl to guard method calls on rendered="false"?  
Perhaps the spec should clear this issue up as I can't be the only one to encounter this 
issue.






Dhananjay Prasanna wrote:
Put it in a h:panelGroup?

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Matthias Wessendorf
Sent: Thursday, 13 July 2006 2:33 PM
To: MyFaces Discussion
Subject: Re: Should ValueBindings inside rendered="false" be evaluated?

I think that div doesn't care about it's children

dataTable for instance does.

-Matthias

On 7/11/06, Matt Hughes <[EMAIL PROTECTED]> wrote:
If you have the following code:

<t:div rendered="false">
    <h:outputText value="#{backingBean.someGetterMethod}" />
</t:div>

Should getSomeGetterMethod() be invoked?  My initial thought was if
the
parent's rendered attribute was false, the value binding expression
*shouldn't* be evaluated.  Using MyFaces 1.1.1 and Facelets 1.10, it
is
being evaluated.

Ideally if rendered is false, than I don't want all the ValueBinding
expressions underneath that tag to be evaluated.

Any thoughts?





--

Matthias Wessendorf

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

This correspondence is for the named persons only.

It may contain confidential or privileged information or both.

No confidentiality or privilege is waived or lost by any mis transmission.

If you receive this correspondence in error please delete it from your system 
immediately and notify the sender.

You must not disclose, copy or relay on any part of this correspondence, if you 
are not the intended recipient.

Any opinions expressed in this message are those of the individual sender 
except where the sender expressly,

and with the authority, states them to be the opinions of the Department of 
Emergency Services, Queensland.



Reply via email to