Hi again,

I have been trying to identify where my problem is. I have come with this
little example. I have a counter that is incremented using a button. If the
button has been rendered by a PPR, the actionListener is not invoked,
whereas if the button was rendered from the start everything works fine.

You can see what I mean here (temporarely, I will stop the server at some
point):

http://elmoska.com:8080/test-webapp/ajaxAndListener.jsf

This is the sample code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
 xmlns:h="http://java.sun.com/jsf/html";
 xmlns:f="http://java.sun.com/jsf/core";
 xmlns:ui="http://java.sun.com/jsf/facelets";
 xmlns:testComposite="http://java.sun.com/jsf/composite/testComposite";
 >
<h:head>
</h:head>
<h:body>
    <h:outputStylesheet name="basic.css"/>
    <h1>Myfaces Examples</h1>
    <h:messages/>

    <h:form id="form">
        <testComposite:compositeCar car="#{carBean.cars[0]}"
owner="#{carBean.owner1}"/>

    </h:form>
</h:body>
</html>

And the backing bean:

package org.apache.myfaces.counter;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@ManagedBean
@SessionScoped
public class CounterBean implements Serializable
{
    private int count;

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public void increment(ActionEvent actionEvent) {
        count++;
    }
}

Is this expected? I don't really know what is expected and what is don't
these days :)

Can provide a svn patch for the test-webapp sample project if needed... but
is basically adding the code above and registering the bean via enabling the
scan context-param or adding it to the faces-config...

Thanks,

Bruno


On 14 May 2010 18:13, Jakob Korherr <[email protected]> wrote:

> You're welcome!
>
> OK, great. If you have a way to reproduce it, I can take a look at it.
>
> Regards,
> Jakob
>
> 2010/5/14 Bruno Aranda <[email protected]>
>
> > I guess that would work too for that example, but for some reason
> c:forEach
> > is not working for me at the moment (using JSP/EL 2.2). I will
> investigate
> > that later...
> >
> > Bruno
> >
> > On 13 May 2010 17:52, Mark Struberg <[email protected]> wrote:
> >
> > > Maybe I'm on the completely wrong track, but does it work with
> c:forEach?
> > >
> > > LieGrue,
> > > strub
> > >
> > > --- On Thu, 5/13/10, Jakob Korherr <[email protected]> wrote:
> > >
> > > > From: Jakob Korherr <[email protected]>
> > > > Subject: Re: Problem with composite component inside ui:repeat
> > > > To: "MyFaces Discussion" <[email protected]>
> > > > Date: Thursday, May 13, 2010, 4:08 PM
> > > > Hi Bruno,
> > > >
> > > > This sounds like a bug. I will investigate it!
> > > >
> > > > Regards,
> > > > Jakob
> > > >
> > > > 2010/5/13 Bruno Aranda <[email protected]>
> > > >
> > > > > Hi,
> > > > >
> > > > > I am having some problems to understand this case:
> > > > >
> > > > > I have a composite component inside a ui:repeat.
> > > > Something like this:
> > > > >
> > > > >  <ui:repeat value="#{testController.objects}"
> > > > var="obj">
> > > > >
> > > >     <myComposite:myComp />
> > > > >  </ui:repeat>
> > > > >
> > > > > And the implementation of the component contains
> > > > this:
> > > > >
> > > > > <composite:implementation>
> > > > >    <h:commandButton value="Say something"
> > > > actionListener="#{cc.sayHello}">
> > > > > <composite:implementation>
> > > > >
> > > > > And I have the corresponding faces component with the
> > > > "sayHEllo"
> > > > > actionListener method.
> > > > >
> > > > > However, I get an exception saying that "cc.sayHello"
> > > > cannot be executed
> > > > > because "cc" is null for that request.
> > > > >
> > > > > Everything works as expected outside the ui:repeat, so
> > > > it seems that for
> > > > > some reason the "cc" is lost after the first request?
> > > > Or is this expected
> > > > > and I am doing something wrong?
> > > > >
> > > > > Thanks!
> > > > >
> > > > > Bruno
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Jakob Korherr
> > > >
> > > > blog: http://www.jakobk.com
> > > > twitter: http://twitter.com/jakobkorherr
> > > > work: http://www.irian.at
> > > >
> > >
> > >
> > >
> > >
> >
>
>
>
> --
> Jakob Korherr
>
> blog: http://www.jakobk.com
> twitter: http://twitter.com/jakobkorherr
> work: http://www.irian.at
>

Reply via email to