-
1. Re: Converter behavior PROBLEM
stephen.friedrich Sep 12, 2007 10:00 AM (in response to urosmil)First assumption whenever the same page gets redisplayed:
Validation failed and your page is missing h:message(s) tags to actually display the validation error messages. -
2. Re: Converter behavior PROBLEM
urosmil Sep 12, 2007 10:22 AM (in response to urosmil)Hi Stephen,
as "validation" are you referring to explicitly added jsf validation, because I don't use that?
This is html code:<h:inputText id="price" value="#{offerBean.offer.price}" converter="offerPriceConvertor" class="inputText"></h:inputText>
I think is important to add that set-er for "offerBean.offer.price" is never executed. After "getAsObject" it's going directly to "getAsString" - by directly I mean it skips my code not the code for handling jsf lifecycle.
Does jsf controller checks object returned by "getAsObject" method? Should't it just call set-er and pass argument returned by "getAsObject" method?
Can someone explain what actually happens behind the scene?
Thanks,
Uros. -
3. Re: Converter behavior PROBLEM
stephen.friedrich Sep 12, 2007 10:30 AM (in response to urosmil)Well have you simply tried to add a single h:messages tag to your page? Let's see if you get any messages.
For example when you use hibernate validation annotations on your entity beans, then seam will add matching jsf validators by itself.
The behaviour you describe is consistent with that: The string object is converted, but validation fails, so it is never transfered to the model.
I am no expert in JSF internals eithers. I am just working my way through "Core Java Server Faces, 2nd edition" and I can really recommend it. -
4. Re: Converter behavior PROBLEM
urosmil Sep 12, 2007 10:56 AM (in response to urosmil)Hi,
it was validation error. I got ""price": Conversion error occurred." from h:messages.
BUT why is validation happening?
I even changed "getAsObject" method body to:public Object getAsObject(FacesContext arg0, UIComponent arg1, String string) { return new BigDecimal(0); }
and I got same error.
Is this some BUG is JSF or Seam or I am doing something wrong?
Thanks,
Uros! -
5. Re: Converter behavior PROBLEM
stephen.friedrich Sep 12, 2007 11:23 AM (in response to urosmil)Hm, let's see how your "offer" bean and especially the "price" property is defined.
-
6. Re: Converter behavior PROBLEM
urosmil Sep 12, 2007 11:46 AM (in response to urosmil)Hi Stephen,
this is offer without irrelevant information:public class Offer implements Serializable, Cloneable { private BigDecimal price; public BigDecimal getPrice() { return price; } public void setPrice(BigDecimal price) { this.price = price; } }
Important to say is that there are situation where I use converter for java.util.List objects and everything work fine.
Thanks,
Uros. -
7. Re: Converter behavior PROBLEM
stephen.friedrich Sep 12, 2007 12:03 PM (in response to urosmil)Ok, I am more or less at the end of my wisdom :-(
Maybe you'll get more info out of h:messages by adding attribute showDetail="true".
Else I would put a breakpoint on FacesContext.addMessage() and try to figure it out from the call stack.