You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Musachy Barroso (JIRA)" <ji...@apache.org> on 2008/07/17 15:59:06 UTC

[jira] Commented: (WW-2722) struts2/ognl confuse setXXX with isXXX method names

    [ https://issues.apache.org/struts/browse/WW-2722?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44403#action_44403 ] 

Musachy Barroso commented on WW-2722:
-------------------------------------

Thanks for reporting and your kind words. Using isX() is a completely valid use case, consider:

<s:checkbox id="username" name="model.user.username"  /> 

In that case, you would expect it to call isUser(), instead of getUser() right? The error message "Error setting expression 'model.user.username' with value '[Ljava.lang.String;@12dcb8c' " is saying that it could not convert the string array to the type of the parameter that ".user" (isUser() in this case) returned. It is designed like this, so it is easy to write the jsps without caring whether it is an "isX" or "getX". What should be changed, is that the parameter binding process should always pick "getX()" and never "isX()".

> struts2/ognl confuse setXXX with isXXX method names
> ---------------------------------------------------
>
>                 Key: WW-2722
>                 URL: https://issues.apache.org/struts/browse/WW-2722
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Expression Language
>    Affects Versions: 2.0.11
>         Environment: Tomcat5.5 winxp eclipse3.3 - struts2.11 with default interceptor stack, spring ioc and jdbc, dead simple crud system
>            Reporter: Etharo
>            Priority: Minor
>
> I had a major problem figuring out why I got this error:
> ERROR http-8180-Processor25 com.opensymphony.xwork2.interceptor.ParametersInterceptor - ParametersInterceptor - [setParameters]: Unexpected Exception caught setting 'model.user.username' on 'class com.mycompany.actions.UserAction: Error setting expression 'model.user.username' with value '[Ljava.lang.String;@12dcb8c'
> *slightly renamed vars/obj
> The model, had these functions:
> public User getUser() { return this.user; }
> public void setUser( User u ) { this.user = u; }
> public boolean isUser() { return ( this.user == null ? false : true ); }
> In my jsp:
> <s:textfield id="username" name="model.user.username" size="8" />
> I have wasted alot of time on this stupid issue. How on earth does the expression confuse model.user.username with getModel().isUser()??? Once the isUser() was removed - everything worked like charm. 
> Struts is full of shitty undebuggable stufs like this, and retarded error msg. I have searched the net all over the place, struts guides, this jira, mailing lists - nothing.
> - The guide needs an update on the matter of NOT POSSIBLE WHAT SO EVER to have a isXXX method.
> - The error message should output what struts/ognl tried to evaluate the string as since it failed. "I failed, sry" doesn't quite help. It would be alot more helpful to see something like "the expression model.user.username was evaluated as getModel().isUser().." and I would maybe easier seen the problem.
> - Add a tiny "if devmodus && foundMessySetGetIsCode() - then println "that isUser() function is maybe messing up stuffs??"
> - Add a setting for dumping stacktraces - a line that says "exception occured" is so not helpfull.
> - Also add functionality to type the method names completely or partially like name="getModel().getUser().setName()" or "model.getUser().name"
> The expressions should only evaluate to set/get methods (unless the last one maybe) since there is alot of focus on that. I can't see any logic behind to go for an isXXX method.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.