I'm experimenting with Struts2 annotations and have some observations
that I'd like clarification on.
1) When using the convention plug-in the book "Apache Struts 2 Web
application Developement states" :
<quote>
The plug-in will scan ... in Java packages whose names contain "struts",
"struts2", "action", and "actions", and whose classname ends in
"Action".
</quote>
What I've found is that the package must end with one of those names,
can I set it to scan for packages actually containing those names?
Also in my configuration I can omit the Action suffix. IE:
testAction.java can be renamed test.java and everything still works.
********************************
2) Well this is not annotation related but when working with the
struts2-json-plugin-2.2.1 I find it interesting that it needs getters
and setters as demonstrated by:
(Take note of the 3 commented lines near the end)
/******************** START *******************/
package struts2;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
@ParentPackage("json-default")
@Result(type = "json")
@Action("simpleJSON")
public class JSONExmapleSimple extends ActionSupport {
public String name = "ken";
public String execute(){
return SUCCESS;
}
//If uncommented action returns {"name":"ken"}
//If commented action returns {}
//public String getName() {return name;}
}
/********************* END ********************/
This is a small detail I don't mind adding getters and setters the IDE
makes it easy but I just find it interesting that this isn't consistent
with what I'd expect based on the struts OGNL access: <s:property
value="I_Only_Need_A_Pulic_Field_Now_Which_Is_Cool"/>
********************************
3) I was wondering if it is possible to apply a struts package
automatically based on the java package name. I wonder this because...
@ParentPackage("json-default") can be applied to the java source package
statement or the Class although when I apply it to the package statement
I receive:
"package annotations should be in file package-info.java" from my IDE
(Netbeans 6.9.1) so if anyone knows if this is a Java standard great
otherwise it's an IDE specific thing and of no further issue here.
So simply that I found @ParentPackage which by it's application to a
package statement and the earlier statement from 1) about the package
name merely needing to contain the string "struts2" (among others) I was
hoping that the last name in the package could be used to specify the
struts xml package to which it belongs? It would be pretty cool!
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]