Moving to the facelets mailing list....

I've been thinking about this a bit, because it seems relevent to my
own issues where el expressions and outputText fields are being cached
somehow.

It doesn't seem like the right behavior to me that a rendered=false
container component would render children and evaluate the el bindings
for the children.

I don't have time to look at it right now, but I'm probably going to
do so later this month.

Venkat, do you have the time to create a small test project
demonstrating this behavior (it seems pretty straight-forward) in
facelets, and possibly also demonstrating how it works under jsp?   If
so, maybe you could open a facelets issue on this, and I'll see if I
can track down why it's happening and maybe submit a patch for it at
some future date.

On 8/1/06, Venkat Rao <[EMAIL PROTECTED]> wrote:

Thanks for the pointer. I am now using <c:forEach> and <c:if> as suggested
by you, and it works better, but not perfectly.

I do a postback in which the graphics object list is modified (one of the
elements is deleted). So the component tree gets modified when rendering
after the postback. Now, the display/behavior of the components rendered is
not correct (missing elements, incorrect bindings etc).

In short, each time my page is rendered, the component tree gets modified in
a significant way, based on the contents of my graphics list, and based on
the type of the object in the list. Using <c:forEach> or <ui:repeat> does
not seem to be cutting it (unless I am doing something wrong)

Is the problem I am having genuine? Is the solution to do a binding of a
UIComponent (like PanelGroup), and (re)create the component tree underneath
it from my Java code (don't quite like this approach, as the Facelet xhtml
expression is much more elegant)

Would appreciate any pointers. Thanks,

-- venkat

-----Original Message-----
From: Sloan, Noah M [mailto:[EMAIL PROTECTED]
Sent: Monday, July 31, 2006 10:16 PM
To: MyFaces Discussion
Subject: RE: "rendered" condition does not work as expected


The problem with using rendered in this way is that Facelets still builds
the component tree for elements that are not rendered, but your component
tree is broken (because the binding you refer to doesn't exist).

This is one of those cases where you actualy need to modify the component
tree based on your condition(instead of turning components on and off) so
you'll probably need to use c:forEach and c:if

-----Original Message-----
From: Venkat Rao [mailto:[EMAIL PROTECTED]
Sent: Mon 31-Jul-06 11:42 AM
To: 'MyFaces Discussion'
Subject: "rendered" condition does not work as expected

My code inside a "rendered" flag is getting invoked even when the condition
is false. I am iterating over a list of Graphics objects to display
information about each by calling the object specific methods. The code
works fine if I use only <h:outputText>. If I use <h:inputText> however, the
rendered property does not seem to be taking effect.

<ui:repeat var="graphicsObj" value="#{gfx.graphicsObjList}">

    <h:panelGroup rendered="#{graphicsObj.objType == 'circle'}" >
        [Circle] Radius: <h:outputText value="#{graphicsObj.radius}"/>
    </h:panelGroup>

    <h:panelGroup rendered="#{graphicsObj.objType == 'rectangle'}" >
        [Rectangle] Length: <h:outputText value="#{graphicsObj.length}"/>
    </h:panelGroup>

</ui:repeat>

The above works fine, as expected. However, if I change from <h:outputText>
to <h:inputText>, it complains :

javax.faces.el.PropertyNotFoundException: /graphics.xhtml @24,54
value="#{graphicsObj.radius}": Bean: Rectangle, property: radius

So, the first block of code is getting executed for a Rectangle object when
using a <h:inputText> but not when using <h:outputText>.

Any help in solving the problem is appreciated. The code for the Circle and
Rectangle beans is given below:

public class Circle implements Serializable
{
    public String getObjType() {
        return "circle";
    }

    int radius;
    public void setRadius(int radius) {
        this.radius = radius;
    }
    public int getRadius() {
        return this.radius;
    }
}

public class Rectangle implements Serializable
{
    public String getObjType() {
        return "rectangle";
    }

    private int length;
    public void setLength(int length) {
        this.length = length;
    }
    public int getLength() {
        return this.length;
    }
}




Reply via email to