Issue Details (XML | Word | Printable)

Key: SHALE-185
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Adam Brod
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Shale

@Value is too restrictive on naming

Created: 07/Jun/06 01:26 AM   Updated: 21/Aug/06 11:28 PM
Return to search
Component/s: Tiger
Affects Version/s: 1.0.3-SNAPSHOT
Fix Version/s: 1.0.3

Environment: Windows XP sp3, Weblogic 9.1, MyFaces 1.1.3


 Description  « Hide
We use a prefix convention for our member variables. All private member fields being with 'm_'. For example, in my managed bean, I have a private field m_fileId with getFileId() and setFileId() methods.

This works fine when I use the faces-config.xml to configure my beans, because I just say the property-name is "fileId". This doesn't work for Shale-Tiger - I get an exception because there is no setter for m_fileId. As far as I know, the Java Beans spec doesn't mandate the name of the private variable, just the getters and setters.

Shale-Tiger should be more flexible to support this.

Here are three possible solutions:

1) The @Value annotation should take an optional property field to allow me to specify the property the field corresponds to. E.g.

@Value(value="#{param.fileId}", property="fileId")
private Long m_fileId;

2) The @Value annotation could be applied to methods or fields (much like JPA annotations). E.g.:
@Value("#{param.fileId}")
public void setFileId(Long fileId) { this.m_fileId = fileId; }

3) I specify some mapping rules somewhere that define all member fields begin with "m_", so the annotation processor should handle that. That is similar to what Eclipse does. You can configure field prefixes, and then the tool automatically handles those when generating getters and setters.


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig McClanahan added a comment - 09/Jun/06 05:02 AM
I agree with your summary statement. At the moment, I'm leaning towards your solution #1, but the idea of annotating a getter or setter (like you can do in JPA entity classes) might also be a good idea.

Repository Revision Date User Message
Struts #417355 Tue Jun 27 06:40:21 UTC 2006 craigmcc SHALE-185 -- Make it possible to specify the name of the managed property
that is annotated by a @Property annotation (@Value is now deprecated, so
do not bother to be backwards compatible with that). The default is to make
the property name match the field name, matching the previous hard coded
behavior. This is also forward compatible with a future scenario where the
@Property annotation might be allowed on a getter or setter method, where
the default property name is derived from the method name, but still
allows overriding the default.
Files Changed
MODIFY /struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/managed/Property.java
MODIFY /struts/shale/trunk/shale-tiger/src/test/java/org/apache/shale/tiger/config/TestBean.java
MODIFY /struts/shale/trunk/shale-tiger/src/main/java/org/apache/shale/tiger/faces/LifecycleListener.java

Craig McClanahan added a comment - 27/Jun/06 01:40 PM
Fixed in nightly build 20060627. You can now optionally specify a "name" attribute on @Property to set the JavaBeans property name being affected.

Craig McClanahan made changes - 27/Jun/06 01:40 PM
Field Original Value New Value
Fix Version/s 1.0.3 [ 21714 ]
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
sean schofield made changes - 21/Aug/06 11:28 PM
Fix Version/s 1.0.3-SNAPSHOT [ 21714 ]
Fix Version/s 1.0.3 [ 21750 ]
Jeff Turner made changes - 09/Aug/07 07:16 AM
Workflow Struts [ 38425 ] Struts - editable closed status [ 42188 ]
Antonio Petrelli made changes - 08/Jan/09 08:57 AM
Workflow Struts - editable closed status [ 42188 ] Struts - editable closed status (temporary) [ 46203 ]
Antonio Petrelli made changes - 08/Jan/09 09:08 AM
Workflow Struts - editable closed status (temporary) [ 46203 ] Struts - editable closed status [ 52614 ]