You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Joe Reger, Jr." <re...@gmail.com> on 2006/06/21 01:15:21 UTC
Managed-bean with another bean as managed-property
Hi!
I'm having some trouble getting JSF to properly set the values of a
backing bean called newOffer when it includes a sub-object called
Offer.
<managed-bean>
<managed-bean-name>newOffer</managed-bean-name>
<managed-bean-class>com.blah.formbeans.NewOffer</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>offer</property-name>
<property-class>com.blah.dao.Offer</property-class>
<value>#{offer}</value>
</managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>offer</managed-bean-name>
<managed-bean-class>com.blah.dao.Offer</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
Note that the newOffer bean had the managed-property called offer
which is another bean. I've successfully done this with a read-only
page and I can use EL like:
<h:outputText value="#{anotherBean.offer.someproperty}"/>
However, when I use the same syntax in an input form like:
<h:inputText value="#{newOffer.offer.someproperty}" id="someproperty">
I get errors. The validation errors per field say ""title": Error
during model data update." and the page errors all say "Conversion
Error."
My backing bean is fairly simple.
public class NewOffer {
private Offer offer;
public NewOffer(){
//I've tried with and without the next line
//offer = new Offer();
}
public String createNewOfferAction(){
//Code in here, but not executed because failure
//appears to be when JSF is populating the model
}
public Offer getOffer() {
return offer;
}
public void setOffer(Offer offer) {
this.offer = offer;
}
}
It appears that JSF is having trouble gaining access to NewOffer.offer
and its properties. It can't successfully complete the second part of
the JSF lifecycle, applying request values to the model. The Offer
object is a well-formed bean with getters and setters.
I don't expect anybody to debug this in detail, but I am hoping that
somebody can tell me whether I'm trying to do something out of the
realm of possibility with JSF. If you can tell me that it's possible
I'll keep at it but so far I've tried many permutations of variable
names, etc.
Thanks,
Joe