You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by _dani <da...@dplanet.ch> on 2006/03/17 08:54:02 UTC

Converter error during Model update

Hello

i have a list of usernames in a listbox, when i select one user and press
the commandbutton i see the id of the user - so far so good. 


<h:form id="myForm">
<h:selectOneListbox value="#{selectedUserBean.selectedUser}"
    converter="User">
  <f:selectitems value="#{userListBean.userList}"/>
</h:selectOneListbox>
 
<h:commandButton action="submit" value="submit"/>
<hr/>
User id: 
  <h:outputText id="edit_id" value="#{selectedUserBean.selectedUser.id}"/>
</h:form>



selectedUserBean: SessionBean
userListBean: RequestBean


public class User {
 private String name;
 private String id;
 
 getters/setters...
}



But now i want to change the user id. so i replace the outputText by

<h:inputText value="#{selectedUserBean.selectedUser.id}"/>



if i now select an user and press the button i always get the error
"converter error duringModel update for component with id: edit_id". And the
inputText filed shows no value.

can someone help me?
--
View this message in context: http://www.nabble.com/Converter-error-during-Model-update-t1296244.html#a3451448
Sent from the MyFaces - Users forum at Nabble.com.


Re: Converter error during Model update

Posted by Mike Kienenberger <mk...@gmail.com>.
On 3/18/06, _dani <da...@dplanet.ch> wrote:
> The selectOneListbox and the inputText component are in the same form on the
> same jsp.
> So i dont now how to control which component is first on my page.

The tags are processed in order of appearance, so if the listbox is
first, it'll be processed (at each phase) first.


> So the problem is located in step 3, validating the inputText component.
> Step 1 is ok, I checked what happens in the userConverter and that looks
> good. There is also no problem during the validation of the
> selectOneListbox. But now during the validation of the inputText component
> in steo 3 selectedUserBean.selectedUser is still null. I think because the
> model wasn't updated yet, the method processUpdates was not called so far.

Yes, that was what I was thinking at first, too, but since you're
still in processValidations, the inputText isn't referencing
selectedUserBean.selectedUser yet.   It's still working with the
component value directly.

> So if I'm right, that tells me that I can't select an edit a user on the
> same page. I need to separate the selection of an user in a first page and
> the modification of the user fields in a second page. But I don't like this
> idea.

The only reason I could see this happening is if the inputText appears
before the selectOneListbox on the page.

Re: Converter error during Model update

Posted by _dani <da...@dplanet.ch>.
Hello again

The selectOneListbox and the inputText component are in the same form on the
same jsp.
So i dont now how to control which component is first on my page.

So the problem is located in step 3, validating the inputText component.
Step 1 is ok, I checked what happens in the userConverter and that looks
good. There is also no problem during the validation of the
selectOneListbox. But now during the validation of the inputText component
in steo 3 selectedUserBean.selectedUser is still null. I think because the
model wasn't updated yet, the method processUpdates was not called so far.

So if I'm right, that tells me that I can't select an edit a user on the
same page. I need to separate the selection of an user in a first page and
the modification of the user fields in a second page. But I don't like this
idea.

I was also looking for similar examples in the web, but haven't found any
yet.

--
View this message in context: http://www.nabble.com/Converter-error-during-Model-update-t1296244.html#a3471562
Sent from the MyFaces - Users forum at Nabble.com.


Re: Converter error during Model update

Posted by Mike Kienenberger <mk...@gmail.com>.
On 3/17/06, _dani <da...@dplanet.ch> wrote:
> The detail message
> of the thrown converter exception is:
> javax.faces.el.PropertyNotFoundException: Base is null: .selectedUser
>
> I'm not sure what this exactly means. Looks for me that there is no instance
> of the class selectedUserBean avaliable. But this class is in session scope
> and should always be accesible...

No, what it means is that selectedUserBean.selectedUser is null.  The
next step would be to figure out why that's the case.   Are you sure
that you've got the selectOneListbox first on your page?  If so, the
order things happen should be:

1) JSF decodes the selectOneListbox component value and the inputText value.
2) JSF converts the selectOneListbox component value and validates it.
3) JSF converts the inputText component value and validates it.
4) JSF puts the selectOneListbox component value into the model
(selectedUserBean.selectedUser).
5) JSF puts the inputText component value into the model.
(selectedUserBean.selectedUser.id).

I'd try setting some breakpoints in step 4 (processUpdates or in your
User converter) and seeing what's going on there.

Re: Converter error during Model update

Posted by _dani <da...@dplanet.ch>.
Hello Mike thx for your reply.

In the UIInput class I set a breakpoint in the method getConvertedValue().
The detail message
of the thrown converter exception is:
javax.faces.el.PropertyNotFoundException: Base is null: .selectedUser

I'm not sure what this exactly means. Looks for me that there is no instance
of the class selectedUserBean avaliable. But this class is in session scope
and should always be accesible...

My handmade stacktrace:

Class: PropertyResolverImpl Method: getProperty the invoke returns null
Class: PropertyResolverImpl Method: getValue returns null
InnerClass: MyPropertySuffix in ELParserHelper Method: evaluate returns null
Class: ValueBindingImpl Method: resolveToBaseAndProperty throws
PropertyNotFoundException
Class: RendererUtils Method: getConvertedUIOutputValue throws
ConverterException
Class: UIInput Method: getConvertedValue finally produces the conversion
error during model update


Hope that thew JSF guys implement a propper exception handling in jsf 1.2;-)


--
View this message in context: http://www.nabble.com/Converter-error-during-Model-update-t1296244.html#a3464618
Sent from the MyFaces - Users forum at Nabble.com.


Re: Converter error during Model update

Posted by Mike Kienenberger <mk...@gmail.com>.
I don't see anything obviously-wrong.

Have you tried setting a breakpoint in the update model code to see
what's going on?

It'd be good to know why the conversion failed.

On 3/17/06, _dani <da...@dplanet.ch> wrote:
>
> Hello
>
> i have a list of usernames in a listbox, when i select one user and press
> the commandbutton i see the id of the user - so far so good.
>
>
> <h:form id="myForm">
> <h:selectOneListbox value="#{selectedUserBean.selectedUser}"
>     converter="User">
>   <f:selectitems value="#{userListBean.userList}"/>
> </h:selectOneListbox>
>
> <h:commandButton action="submit" value="submit"/>
> <hr/>
> User id:
>   <h:outputText id="edit_id" value="#{selectedUserBean.selectedUser.id}"/>
> </h:form>
>
>
>
> selectedUserBean: SessionBean
> userListBean: RequestBean
>
>
> public class User {
>  private String name;
>  private String id;
>
>  getters/setters...
> }
>
>
>
> But now i want to change the user id. so i replace the outputText by
>
> <h:inputText value="#{selectedUserBean.selectedUser.id}"/>
>
>
>
> if i now select an user and press the button i always get the error
> "converter error duringModel update for component with id: edit_id". And the
> inputText filed shows no value.
>
> can someone help me?
> --
> View this message in context: http://www.nabble.com/Converter-error-during-Model-update-t1296244.html#a3451448
> Sent from the MyFaces - Users forum at Nabble.com.
>
>