Hi all,
I have a problem with Struts2 type conversion. Here is the classes:
public class Square {
private int id;
private Set points = new HashSet();
public Square() {
}
public Square(int id, Set points) {
this.id = id;
this.points = points;
}
//Setters and getters
}
public class Point {
private int x;
private int y;
public Point() {
}
public Point(int x, int y) {
this.x = x;
this.y = y;
}
}
JSP:
<s:form action="set_submission">
<s:textfield name="square.points.makeNew[0].x" label="x:
"></s:textfield>
<s:textfield name="square.points.makeNew[0].y" label="y:
"></s:textfield>
<s:textfield name="square.points(1).x" label="x:
"></s:textfield>
<s:textfield name="square.points(1).y" label="y:
"></s:textfield>
<s:textfield name="points(2).x" label="x: "></s:textfield>
<s:textfield name="points(2).y" label="y: "></s:textfield>
<s:submit></s:submit>
</s:form>
SetSubmission-conversion.properties:
Element_point=com.test.bean.Point
KeyProperty_points=x
CreateIfNull_points = true
Action:
public class SetSubmission extends ActionSupport {
private Set<Point> points = new HashSet<Point>();
private Square square = new Square();
public String execute() throws Exception {
System.out.println("points: " + points.size());
for(Point p : points) {
System.out.println("X = " + p.getX() + ", Y = "
+ p.getY());
}
System.out.println("square.points: " +
square.getPoints().size());
for(Point p : (Set<Point>) square.getPoints()) {
System.out.println("X = " + p.getX() + ", Y = "
+ p.getY());
}
return SUCCESS;
}
Here I want the JSP page to submit values directly into the Set 'points'
in Action class. How can I do this?
I managed to submit values directly into the Set<Point> points
collection. However, when it comes to a set inside another object, it
doesn't work.
Any help would be very much appreciated.
Cheers,
Jipu
-----Original Message-----
From: Peter Bliznak [mailto:[email protected]]
Sent: 11 February 2010 18:14
To: Struts Users Mailing List
Subject: Reading properties from separate source folder
Hi all,
here's my problem. How do I make S2 read property files from separate
folder.
We have different properties for prod, uat and so on ... so we want the
have
separate folder which will contain different set of files for each
environment.
in S1 we used to have two source folders one for java files and second
for all properties.
I tried same thing here and I can't make it work or maybe it is not even
supported.Any ideas?
Peter.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]