You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Jeromy Evans (JIRA)" <ji...@apache.org> on 2008/07/18 02:43:05 UTC

[jira] Resolved: (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:all-tabpanel ]

Jeromy Evans resolved WW-2722.
------------------------------

    Resolution: Not A Problem
      Assignee: Jeromy Evans


It is inappropriate and non-compliant to have both a getXXX and isXXX for the same property that return different values.  
This is just an elementary misunderstanding of java bean accessors by Etharo.

The remainder of the rant contains some useful suggestions, so I've reworded the key point of that into WW-2723.

> 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
>            Assignee: Jeromy Evans
>            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.