RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread adam pinder

 
have you got the correct cascade setting on the parent object
 
i use the xml files for hibernate rather than the @ syntax in java classes and 
i can set cascade=all which means when i save/update the parent the children 
are also saved or updated.
 
also remember that for hibernate to realise the children need to be updated 
rather than saved, the child object needs to have a primary key set otherwise 
it will want to do a save ... and if cascade was only update then nothing would 
be done with child objects.
 
turn on debugging of sql in hibernate config file to see if any sql to 
update/save children is actually being created.
 



 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Wed, 31 Mar 2010 22:15:34 +0200

 Dear Rene,

 Thks a lot for replying to me because I am feeling a little bit alone with
 my CRUD ;-). In fact I am trying to build a dynamic MetaCrud.
 My pb is simple: in the same jsp page I would like to update a Parent object
 and its Childs (values):

 
 
 name=name label=Nom /
 
 
 
 
 
 
 
 

 From an existing Parent object with many Childs objects I can easily modify
 parent.name for instance but the collection of Child objects (values) is
 always empty in the ParentAction (saveOrUpdate() method) after submitting.
 However I can display each values[i].name in the jsp page with the correct
 value.
 So it is not an issue with Hibernate but with the jsp or ModelDriven
 interface I don't know..Do you have any idea?
 Basically I was not able to find a struts or spring documentation about CRUD
  association between two entities on the same jsp page.
 best regards
 bruno



 --
 From: Rene Gielen 
 Sent: Wednesday, March 31, 2010 7:12 PM
 To: Struts Users Mailing List 
 Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3

 I'm not sure if I understand what your actual question is, nor whether
 it is particularly Struts 2 related (rather than just Hibernate) - but
 you might want to have a look in the CRUD demo section of the Struts 2
 showcase application. Maybe you will also find this demo useful:
 http://github.com/rgielen/struts2crudevolutiondemo

 - René

 bruno grandjean schrieb:
 Hi

 I am trying to implement a simple CRUD with a OneToMany association under
 Struts 2 / Hibernate 3.
 I have two entities Parent and Child:

 @Entity
 @Table(name=PARENT)
 public class Parent {
 private Long id;
 private Set values = new HashSet();
 ..
 @Entity
 @Table(name=CHILD)
 public class Child {
 private Long id;
 private String name;
 ..

 I can easily create, delete Parent or read the Child Set (values) but it
 is impossible to update Child Set.
 The jsp page (see below) reinit the values Set, no record after updating!
 Could u explain to me what's wrong?

 here are my code:

 @Entity
 @Table(name=PARENT)
 public class Parent {
 private Long id;
 private Set values = new HashSet();
 @Id
 @GeneratedValue
 @Column(name=PARENT_ID)
 public Long getId() {
 return id;
 }
 public void setId(Long id) {
 this.id = id;
 }
 @ManyToMany(fetch = FetchType.EAGER)
 @JoinTable(name = PARENT_CHILD, joinColumns = { @JoinColumn(name =
 PARENT_ID) }, inverseJoinColumns = { @JoinColumn(name = CHILD_ID) })
 public Set getValues() {
 return values;
 }
 public void setValues(Set lst) {
 values = lst;
 }
 }

 @Entity
 @Table(name=CHILD)
 public class Child {
 private Long id;
 private String name;
 @Id
 @GeneratedValue
 @Column(name=CHILD_ID)
 public Long getId() {
 return id;
 }
 public void setId(Long id) {
 this.id = id;
 }
 @Column(name=NAME)
 public String getName() {
 return name;
 }
 public void setName(String val) {
 name = val;
 }
 }

 public interface ParentDAO {
 public void saveOrUpdateParent(Parent cl);
 public void saveParent(Parent cl);
 public List listParent();
 public Parent listParentById(Long clId);
 public void deleteParent(Long clId);
 }

 public class ParentDAOImpl implements ParentDAO {
 @SessionTarget
 Session session;
 @TransactionTarget
 Transaction transaction;

 @Override
 public void saveOrUpdateParent(Parent cl) {
 try {
 session.saveOrUpdate(cl);
 } catch (Exception e) {
 transaction.rollback();
 e.printStackTrace();
 }
 }

 @Override
 public void saveParent(Parent cl) {
 try {
 session.save(cl);
 } catch (Exception e) {
 transaction.rollback();
 e.printStackTrace();
 }
 }

 @Override
 public void deleteParent(Long clId) {
 try {
 Parent cl = (Parent) session.get(Parent.class, clId);
 session.delete(cl);
 } catch (Exception e) {
 transaction.rollback();
 e.printStackTrace();
 }
 }

 @SuppressWarnings(unchecked)
 @Override
 public List listParent() {
 List courses = null;
 try {
 courses = session.createQuery(from Parent).list();
 } catch (Exception e) {
 e.printStackTrace();
 }
 return courses;
 }

 @Override
 public Parent listParentById(Long clId) {
 Parent cl = null;
 try {
 cl = (Parent) 

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean

Dear Adam,
 
I wrote a CascadeType.ALL in my @OneToMany annotation:
 

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) 
@JoinTable(name = PARENT_CHILD, joinColumns = { @JoinColumn(name = 
PARENT_ID) }, inverseJoinColumns = { @JoinColumn(name = CHILD_ID) }) 
public SetChild getValues() { 
return values;}
 
but I got unfortunately the same result.
 
Before running the application I execute the following hsqldb script:
 
insert into CHILD (CHILD_ID, NAME) values (1, 'Child1');
insert into CHILD (CHILD_ID, NAME) values (2, 'Child2');
insert into PARENT (PARENT_ID, NAME) values (1, 'Parent1');
insert into PARENT_CHILD (PARENT_ID, CHILD_ID) values (1, 1);
insert into PARENT_CHILD (PARENT_ID, CHILD_ID) values (1, 2);

After that, in the jsp page I have no pb to modify the fields:
 
1
Nom: Parent1
Id: 1
Nom: Child1
Id: 2
Nom: Child 2

s:form action=saveOrUpdateParent

s:push value=parent
s:hidden name=id / 
s:textfield name=name label=Nom /
s:push value=values
s:iterator id=p value=values
s:textfield label=Id name=#id value=%{id} /
s:textfield label=Nom name=#name value=%{name}/
/s:iterator
/s:push



s:submit /


/s:push
/s:form
 
I do not modify any keys which are auto-generated with Hibernate annotations:

 

@Id
@GeneratedValue


Iin debug mode just after clicking the submit button the size of Child Set is 
0, I lost all my Child objects which is abnormal.
After running the session.saveOrUpdate(parent) method the hibernate trace is:
 


Hibernate: update PARENT set NAME=? where PARENT_ID=?
Hibernate: delete from PARENT_CHILD where PARENT_ID=?
 
So I am little bit lost because I do not know how to keep my Child Set alive..

 

All the best

 

Bruno


 
 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 07:46:59 +0100
 
 
 
 have you got the correct cascade setting on the parent object
 
 i use the xml files for hibernate rather than the @ syntax in java classes 
 and i can set cascade=all which means when i save/update the parent the 
 children are also saved or updated.
 
 also remember that for hibernate to realise the children need to be updated 
 rather than saved, the child object needs to have a primary key set otherwise 
 it will want to do a save ... and if cascade was only update then nothing 
 would be done with child objects.
 
 turn on debugging of sql in hibernate config file to see if any sql to 
 update/save children is actually being created.
 
 
 
 
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Wed, 31 Mar 2010 22:15:34 +0200
 
  Dear Rene,
 
  Thks a lot for replying to me because I am feeling a little bit alone with
  my CRUD ;-). In fact I am trying to build a dynamic MetaCrud.
  My pb is simple: in the same jsp page I would like to update a Parent object
  and its Childs (values):
 
  
  
  name=name label=Nom /
  
  
  
  
  
  
  
  
 
  From an existing Parent object with many Childs objects I can easily modify
  parent.name for instance but the collection of Child objects (values) is
  always empty in the ParentAction (saveOrUpdate() method) after submitting.
  However I can display each values[i].name in the jsp page with the correct
  value.
  So it is not an issue with Hibernate but with the jsp or ModelDriven
  interface I don't know..Do you have any idea?
  Basically I was not able to find a struts or spring documentation about CRUD
   association between two entities on the same jsp page.
  best regards
  bruno
 
 
 
  --
  From: Rene Gielen 
  Sent: Wednesday, March 31, 2010 7:12 PM
  To: Struts Users Mailing List 
  Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 
  I'm not sure if I understand what your actual question is, nor whether
  it is particularly Struts 2 related (rather than just Hibernate) - but
  you might want to have a look in the CRUD demo section of the Struts 2
  showcase application. Maybe you will also find this demo useful:
  http://github.com/rgielen/struts2crudevolutiondemo
 
  - René
 
  bruno grandjean schrieb:
  Hi
 
  I am trying to implement a simple CRUD with a OneToMany association under
  Struts 2 / Hibernate 3.
  I have two entities Parent and Child:
 
  @Entity
  @Table(name=PARENT)
  public class Parent {
  private Long id;
  private Set values = new HashSet();
  ..
  @Entity
  @Table(name=CHILD)
  public class Child {
  private Long id;
  private String name;
  ..
 
  I can easily create, delete Parent or read the Child Set (values) but it
  is impossible to update Child Set.
  The jsp page (see below) reinit the values Set, no record after updating!
  Could u explain to me what's wrong?
 
  here are my code:
 
  @Entity
  @Table(name=PARENT)
  public class Parent {
  private Long id;
  private Set values = new 

Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread Rene Gielen
Given the model you presented in the first post, your problem seems to
be that the posted values have not the correct name for the children's
form fields. The parameters names you would need are

id
name
values[0].id
values[0].name
values[1].id
values[2].name
...

for the parameters interceptor to work properly when applying the posted
values.

See here for more details:
http://struts.apache.org/2.1.8/docs/tabular-inputs.html

- René

bruno grandjean schrieb:
 Dear Rene,
 
 Thks a lot for replying to me because I am feeling a little bit alone with
 my CRUD ;-). In fact I am trying to build a dynamic MetaCrud.
 My pb is simple: in the same jsp page I would like to update a Parent
 object
 and its Childs (values):
 
 s:form action=saveOrUpdateParent
 s:push value=parent
 s:hidden name=id / s:textfield
 name=name label=Nom /
 s:push value=values
  s:iterator id=p value=values
s:textfield label=Nom name=#name value=%{name}/
/s:iterator
 /s:push
 s:submit /
 /s:push
 /s:form
 
 From an existing Parent object with many Childs objects I can easily modify
 parent.name for instance but the collection of Child objects (values) is
 always empty in the ParentAction (saveOrUpdate() method) after submitting.
 However I can display each values[i].name in the jsp page with the correct
 value.
 So it is not an issue with Hibernate but with the jsp or ModelDriven
 interface I don't know..Do you have any idea?
 Basically I was not able to find a struts or spring documentation about
 CRUD
  association between two entities on the same jsp page.
 best regards
 bruno
 
 
 
 --
 From: Rene Gielen gie...@it-neering.net
 Sent: Wednesday, March 31, 2010 7:12 PM
 To: Struts Users Mailing List user@struts.apache.org
 Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 
 I'm not sure if I understand what your actual question is, nor whether
 it is particularly Struts 2 related (rather than just Hibernate) - but
 you might want to have a look in the CRUD demo section of the Struts 2
 showcase application. Maybe you will also find this demo useful:
 http://github.com/rgielen/struts2crudevolutiondemo

 - René

 bruno grandjean schrieb:
 Hi

 I am trying to implement a simple CRUD with a OneToMany association
 under Struts 2 / Hibernate 3.
 I have two entities Parent and Child:

 @Entity
 @Table(name=PARENT)
 public class Parent {
  private Long id;
  private SetChild values = new HashSetChild();
 ..
 @Entity
 @Table(name=CHILD)
 public class Child {
  private Long id;
  private String name;
 ..

 I can easily create, delete Parent or read the Child Set (values) but
 it is impossible to update Child Set.
 The jsp page (see below) reinit the values Set, no record after
 updating!
 Could u explain to me what's wrong?

 here are my code:

 @Entity
 @Table(name=PARENT)
 public class Parent {
  private Long id;
  private SetChild values = new HashSetChild();
  @Id
  @GeneratedValue
  @Column(name=PARENT_ID)
  public Long getId() {
   return id;
  }
  public void setId(Long id) {
   this.id = id;
  }
  @ManyToMany(fetch = FetchType.EAGER)
  @JoinTable(name = PARENT_CHILD, joinColumns = { @JoinColumn(name =
 PARENT_ID) }, inverseJoinColumns = { @JoinColumn(name = CHILD_ID) })
  public SetChild getValues() {
   return values;
  }
  public void setValues(SetChild lst) {
   values = lst;
  }
 }

 @Entity
 @Table(name=CHILD)
 public class Child {
  private Long id;
  private String name;
  @Id
  @GeneratedValue
  @Column(name=CHILD_ID)
  public Long getId() {
   return id;
  }
  public void setId(Long id) {
   this.id = id;
  }
  @Column(name=NAME)
  public String getName() {
   return name;
  }
  public void setName(String val) {
   name = val;
  }
 }

 public interface ParentDAO {
  public void saveOrUpdateParent(Parent cl);
  public void saveParent(Parent cl);
  public ListParent listParent();
  public Parent listParentById(Long clId);
  public void deleteParent(Long clId);
 }

 public class ParentDAOImpl implements ParentDAO {
  @SessionTarget
  Session session;
  @TransactionTarget
  Transaction transaction;

  @Override
  public void saveOrUpdateParent(Parent cl) {
   try {
session.saveOrUpdate(cl);
   } catch (Exception e) {
transaction.rollback();
e.printStackTrace();
   }
  }

  @Override
  public void saveParent(Parent cl) {
   try {
session.save(cl);
   } catch (Exception e) {
transaction.rollback();
e.printStackTrace();
   }
  }

  @Override
  public void deleteParent(Long clId) {
   try {
Parent cl = (Parent) session.get(Parent.class, clId);
session.delete(cl);
   } catch (Exception e) {
transaction.rollback();
e.printStackTrace();
   }
  }

  @SuppressWarnings(unchecked)
  @Override
  public ListParent listParent() {
   ListParent courses = null;
   try {
courses = session.createQuery(from Parent).list();
} catch (Exception e) {
e.printStackTrace();
   }
   return courses;
  }

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean

Dear René

 

I changed my jsp page so as to integrate the following block:

 

s:iterator value=parent.values status=rowstatus
s:hidden name=parent.values[%{#rowstatus.index}].id value=%{id} /
s:textfield name=parent.values[%{#rowstatus.index}].name value=%{name} / 
/s:iterator

 

which generates the following html code:

 

input type=hidden name=parent.values[0].id value=1 
id=saveOrUpdateParent_parent_values_0__id/

tr

td class=tdLabel/td

tdinput type=text name=parent.values[0].name value=Child1 
id=saveOrUpdateParent_parent_values_0__name//td

/tr  

input type=hidden name=parent.values[1].id value=2 
id=saveOrUpdateParent_parent_values_1__id/

tr

td class=tdLabel/td

td

input type=text name=parent.values[1].name value=Child2 
id=saveOrUpdateParent_parent_values_1__name//td

/tr
  

I can display my complete Child Set but I got the same result after updating: 
my Child Set is empty.

 

Is that necessary to modify my ParentAction as well? If yes what to do?

 

public class ParentAction extends ActionSupport implements ModelDrivenParent {

private static final long serialVersionUID = -2662966220408285700L;
private Parent cl = new Parent();
private ListParent clList = new ArrayListParent(); 
private ParentDAO clDAO = new ParentDAOImpl();

@Override
public Parent getModel() {
return cl;
}

public String saveOrUpdate()
{ // cl.values is empty here!!
clDAO.saveOrUpdateParent(cl); 
return SUCCESS;
}

public String save()
{ 
clDAO.saveParent(cl); 
return SUCCESS;
}

public String list()
{
clList = clDAO.listParent();
return SUCCESS;
}

public String delete()
{
HttpServletRequest request = (HttpServletRequest) 
ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
clDAO.deleteParent(Long.parseLong(request.getParameter(id)));
return SUCCESS;
}

public String edit()
{ // cl.values contains some valid Child elements here!!
HttpServletRequest request = (HttpServletRequest) 
ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
cl = clDAO.listParentById(Long.parseLong(request.getParameter(id)));
} 
return SUCCESS;
}

public Parent getParent() {
return cl;
}

public void setParent(Parent cl) {
this.cl = cl;
}

public ListParent getParentList() {
return clList;
}

public void setParentList(ListParent clList) {
this.clList = clList;
}
}


 
 Date: Thu, 1 Apr 2010 11:30:23 +0200
 From: gie...@it-neering.net
 To: user@struts.apache.org
 Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 
 Given the model you presented in the first post, your problem seems to
 be that the posted values have not the correct name for the children's
 form fields. The parameters names you would need are
 
 id
 name
 values[0].id
 values[0].name
 values[1].id
 values[2].name
 ...
 
 for the parameters interceptor to work properly when applying the posted
 values.
 
 See here for more details:
 http://struts.apache.org/2.1.8/docs/tabular-inputs.html
 
 - René
 
 bruno grandjean schrieb:
  Dear Rene,
  
  Thks a lot for replying to me because I am feeling a little bit alone with
  my CRUD ;-). In fact I am trying to build a dynamic MetaCrud.
  My pb is simple: in the same jsp page I would like to update a Parent
  object
  and its Childs (values):
  
  s:form action=saveOrUpdateParent
  s:push value=parent
  s:hidden name=id / s:textfield
  name=name label=Nom /
  s:push value=values
  s:iterator id=p value=values
  s:textfield label=Nom name=#name value=%{name}/
  /s:iterator
  /s:push
  s:submit /
  /s:push
  /s:form
  
  From an existing Parent object with many Childs objects I can easily modify
  parent.name for instance but the collection of Child objects (values) is
  always empty in the ParentAction (saveOrUpdate() method) after submitting.
  However I can display each values[i].name in the jsp page with the correct
  value.
  So it is not an issue with Hibernate but with the jsp or ModelDriven
  interface I don't know..Do you have any idea?
  Basically I was not able to find a struts or spring documentation about
  CRUD
   association between two entities on the same jsp page.
  best regards
  bruno
  
  
  
  --
  From: Rene Gielen gie...@it-neering.net
  Sent: Wednesday, March 31, 2010 7:12 PM
  To: Struts Users Mailing List user@struts.apache.org
  Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  
  I'm not sure if I understand what your actual question is, nor whether
  it is particularly Struts 2 related (rather than just Hibernate) - but
  you might want to have a look in the CRUD demo section of the Struts 2
  showcase application. Maybe you will also find this demo useful:
  http://github.com/rgielen/struts2crudevolutiondemo
 
  - René
 
  bruno grandjean schrieb:
  Hi
 
  I am trying to implement a simple CRUD with a OneToMany association
  under Struts 2 / Hibernate 3.
  I have two entities Parent and Child:
 
  @Entity
  @Table(name=PARENT)
  public class Parent {
  private Long id;
  

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread adam pinder

 
 
turn on the parameterinterceptor logging and make sure as mentioned that 
 
1) the values you expect for each child are being sent to the server (id and 
name)
2) the parameter names are correct for setting each child
 
i had some issues getting lists of items to be updated by form submission alone.
 
for example does your parent object have a getValues method taking an index 
value
 
getParent().getValues(1).setId(1)
getParent().getValues(1).setName(bob)
 
would be called by parameterinterceptor



 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:16:09 +0200


 Dear René



 I changed my jsp page so as to integrate the following block:



 
 
 
 



 which generates the following html code:



 

 

 

 

 

 

 

 

 

 

 


 I can display my complete Child Set but I got the same result after updating: 
 my Child Set is empty.



 Is that necessary to modify my ParentAction as well? If yes what to do?



 public class ParentAction extends ActionSupport implements ModelDriven {

 private static final long serialVersionUID = -2662966220408285700L;
 private Parent cl = new Parent();
 private List clList = new ArrayList();
 private ParentDAO clDAO = new ParentDAOImpl();

 @Override
 public Parent getModel() {
 return cl;
 }

 public String saveOrUpdate()
 { // cl.values is empty here!!
 clDAO.saveOrUpdateParent(cl);
 return SUCCESS;
 }

 public String save()
 {
 clDAO.saveParent(cl);
 return SUCCESS;
 }

 public String list()
 {
 clList = clDAO.listParent();
 return SUCCESS;
 }

 public String delete()
 {
 HttpServletRequest request = (HttpServletRequest) 
 ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
 clDAO.deleteParent(Long.parseLong(request.getParameter(id)));
 return SUCCESS;
 }

 public String edit()
 { // cl.values contains some valid Child elements here!!
 HttpServletRequest request = (HttpServletRequest) 
 ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
 cl = clDAO.listParentById(Long.parseLong(request.getParameter(id)));
 }
 return SUCCESS;
 }

 public Parent getParent() {
 return cl;
 }

 public void setParent(Parent cl) {
 this.cl = cl;
 }

 public List getParentList() {
 return clList;
 }

 public void setParentList(List clList) {
 this.clList = clList;
 }
 }



 Date: Thu, 1 Apr 2010 11:30:23 +0200
 From: gie...@it-neering.net
 To: user@struts.apache.org
 Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3

 Given the model you presented in the first post, your problem seems to
 be that the posted values have not the correct name for the children's
 form fields. The parameters names you would need are

 id
 name
 values[0].id
 values[0].name
 values[1].id
 values[2].name
 ...

 for the parameters interceptor to work properly when applying the posted
 values.

 See here for more details:
 http://struts.apache.org/2.1.8/docs/tabular-inputs.html

 - René

 bruno grandjean schrieb:
 Dear Rene,

 Thks a lot for replying to me because I am feeling a little bit alone with
 my CRUD ;-). In fact I am trying to build a dynamic MetaCrud.
 My pb is simple: in the same jsp page I would like to update a Parent
 object
 and its Childs (values):

 
 
 name=name label=Nom /
 
 
 
 
 
 
 
 

 From an existing Parent object with many Childs objects I can easily modify
 parent.name for instance but the collection of Child objects (values) is
 always empty in the ParentAction (saveOrUpdate() method) after submitting.
 However I can display each values[i].name in the jsp page with the correct
 value.
 So it is not an issue with Hibernate but with the jsp or ModelDriven
 interface I don't know..Do you have any idea?
 Basically I was not able to find a struts or spring documentation about
 CRUD
  association between two entities on the same jsp page.
 best regards
 bruno



 --
 From: Rene Gielen 
 Sent: Wednesday, March 31, 2010 7:12 PM
 To: Struts Users Mailing List 
 Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3

 I'm not sure if I understand what your actual question is, nor whether
 it is particularly Struts 2 related (rather than just Hibernate) - but
 you might want to have a look in the CRUD demo section of the Struts 2
 showcase application. Maybe you will also find this demo useful:
 http://github.com/rgielen/struts2crudevolutiondemo

 - René

 bruno grandjean schrieb:
 Hi

 I am trying to implement a simple CRUD with a OneToMany association
 under Struts 2 / Hibernate 3.
 I have two entities Parent and Child:

 @Entity
 @Table(name=PARENT)
 public class Parent {
 private Long id;
 private Set values = new HashSet();
 ..
 @Entity
 @Table(name=CHILD)
 public class Child {
 private Long id;
 private String name;
 ..

 I can easily create, delete Parent or read the Child Set (values) but
 it is impossible to update 

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean

Dear Adam,

 

I just added a public Child getValues(int idx) in the Parent class definition 
but it is never called.

 

Could u explain to me where and how can I turn on the parameterinterceptor 
logging? In the struts.xml file?

 

thks a lot


bruno

 


 
 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:18:48 +0100
 
 
 
 
 turn on the parameterinterceptor logging and make sure as mentioned that 
 
 1) the values you expect for each child are being sent to the server (id and 
 name)
 2) the parameter names are correct for setting each child
 
 i had some issues getting lists of items to be updated by form submission 
 alone.
 
 for example does your parent object have a getValues method taking an index 
 value
 
 getParent().getValues(1).setId(1)
 getParent().getValues(1).setName(bob)
 
 would be called by parameterinterceptor
 
 
 
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 12:16:09 +0200
 
 
  Dear René
 
 
 
  I changed my jsp page so as to integrate the following block:
 
 
 
  
  
  
  
 
 
 
  which generates the following html code:
 
 
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
  
 
 
  I can display my complete Child Set but I got the same result after 
  updating: my Child Set is empty.
 
 
 
  Is that necessary to modify my ParentAction as well? If yes what to do?
 
 
 
  public class ParentAction extends ActionSupport implements ModelDriven {
 
  private static final long serialVersionUID = -2662966220408285700L;
  private Parent cl = new Parent();
  private List clList = new ArrayList();
  private ParentDAO clDAO = new ParentDAOImpl();
 
  @Override
  public Parent getModel() {
  return cl;
  }
 
  public String saveOrUpdate()
  { // cl.values is empty here!!
  clDAO.saveOrUpdateParent(cl);
  return SUCCESS;
  }
 
  public String save()
  {
  clDAO.saveParent(cl);
  return SUCCESS;
  }
 
  public String list()
  {
  clList = clDAO.listParent();
  return SUCCESS;
  }
 
  public String delete()
  {
  HttpServletRequest request = (HttpServletRequest) 
  ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
  clDAO.deleteParent(Long.parseLong(request.getParameter(id)));
  return SUCCESS;
  }
 
  public String edit()
  { // cl.values contains some valid Child elements here!!
  HttpServletRequest request = (HttpServletRequest) 
  ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
  cl = clDAO.listParentById(Long.parseLong(request.getParameter(id)));
  }
  return SUCCESS;
  }
 
  public Parent getParent() {
  return cl;
  }
 
  public void setParent(Parent cl) {
  this.cl = cl;
  }
 
  public List getParentList() {
  return clList;
  }
 
  public void setParentList(List clList) {
  this.clList = clList;
  }
  }
 
 
 
  Date: Thu, 1 Apr 2010 11:30:23 +0200
  From: gie...@it-neering.net
  To: user@struts.apache.org
  Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 
  Given the model you presented in the first post, your problem seems to
  be that the posted values have not the correct name for the children's
  form fields. The parameters names you would need are
 
  id
  name
  values[0].id
  values[0].name
  values[1].id
  values[2].name
  ...
 
  for the parameters interceptor to work properly when applying the posted
  values.
 
  See here for more details:
  http://struts.apache.org/2.1.8/docs/tabular-inputs.html
 
  - René
 
  bruno grandjean schrieb:
  Dear Rene,
 
  Thks a lot for replying to me because I am feeling a little bit alone with
  my CRUD ;-). In fact I am trying to build a dynamic MetaCrud.
  My pb is simple: in the same jsp page I would like to update a Parent
  object
  and its Childs (values):
 
  
  
  name=name label=Nom /
  
  
  
  
  
  
  
  
 
  From an existing Parent object with many Childs objects I can easily 
  modify
  parent.name for instance but the collection of Child objects (values) is
  always empty in the ParentAction (saveOrUpdate() method) after submitting.
  However I can display each values[i].name in the jsp page with the correct
  value.
  So it is not an issue with Hibernate but with the jsp or ModelDriven
  interface I don't know..Do you have any idea?
  Basically I was not able to find a struts or spring documentation about
  CRUD
   association between two entities on the same jsp page.
  best regards
  bruno
 
 
 
  --
  From: Rene Gielen 
  Sent: Wednesday, March 31, 2010 7:12 PM
  To: Struts Users Mailing List 
  Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 
  3
 
  I'm not sure if I understand what your actual question is, nor whether
  it is particularly Struts 2 related (rather than just Hibernate) - but
  you might want to have a look 

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread adam pinder

 
 
in log4j.properties file (same location as struts.xml and hibernate config 
files)
 
add
 
log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug
 
this will output param name/value pairs being posted from your page.
 



 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 13:54:33 +0200


 Dear Adam,



 I just added a public Child getValues(int idx) in the Parent class definition 
 but it is never called.



 Could u explain to me where and how can I turn on the parameterinterceptor 
 logging? In the struts.xml file?



 thks a lot


 bruno





 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:18:48 +0100




 turn on the parameterinterceptor logging and make sure as mentioned that

 1) the values you expect for each child are being sent to the server (id and 
 name)
 2) the parameter names are correct for setting each child

 i had some issues getting lists of items to be updated by form submission 
 alone.

 for example does your parent object have a getValues method taking an index 
 value

 getParent().getValues(1).setId(1)
 getParent().getValues(1).setName(bob)

 would be called by parameterinterceptor


 
 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:16:09 +0200


 Dear René



 I changed my jsp page so as to integrate the following block:










 which generates the following html code:


























 I can display my complete Child Set but I got the same result after 
 updating: my Child Set is empty.



 Is that necessary to modify my ParentAction as well? If yes what to do?



 public class ParentAction extends ActionSupport implements ModelDriven {

 private static final long serialVersionUID = -2662966220408285700L;
 private Parent cl = new Parent();
 private List clList = new ArrayList();
 private ParentDAO clDAO = new ParentDAOImpl();

 @Override
 public Parent getModel() {
 return cl;
 }

 public String saveOrUpdate()
 { // cl.values is empty here!!
 clDAO.saveOrUpdateParent(cl);
 return SUCCESS;
 }

 public String save()
 {
 clDAO.saveParent(cl);
 return SUCCESS;
 }

 public String list()
 {
 clList = clDAO.listParent();
 return SUCCESS;
 }

 public String delete()
 {
 HttpServletRequest request = (HttpServletRequest) 
 ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
 clDAO.deleteParent(Long.parseLong(request.getParameter(id)));
 return SUCCESS;
 }

 public String edit()
 { // cl.values contains some valid Child elements here!!
 HttpServletRequest request = (HttpServletRequest) 
 ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
 cl = clDAO.listParentById(Long.parseLong(request.getParameter(id)));
 }
 return SUCCESS;
 }

 public Parent getParent() {
 return cl;
 }

 public void setParent(Parent cl) {
 this.cl = cl;
 }

 public List getParentList() {
 return clList;
 }

 public void setParentList(List clList) {
 this.clList = clList;
 }
 }



 Date: Thu, 1 Apr 2010 11:30:23 +0200
 From: gie...@it-neering.net
 To: user@struts.apache.org
 Subject: Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3

 Given the model you presented in the first post, your problem seems to
 be that the posted values have not the correct name for the children's
 form fields. The parameters names you would need are

 id
 name
 values[0].id
 values[0].name
 values[1].id
 values[2].name
 ...

 for the parameters interceptor to work properly when applying the posted
 values.

 See here for more details:
 http://struts.apache.org/2.1.8/docs/tabular-inputs.html

 - René

 bruno grandjean schrieb:
 Dear Rene,

 Thks a lot for replying to me because I am feeling a little bit alone with
 my CRUD ;-). In fact I am trying to build a dynamic MetaCrud.
 My pb is simple: in the same jsp page I would like to update a Parent
 object
 and its Childs (values):



 name=name label=Nom /









 From an existing Parent object with many Childs objects I can easily 
 modify
 parent.name for instance but the collection of Child objects (values) is
 always empty in the ParentAction (saveOrUpdate() method) after submitting.
 However I can display each values[i].name in the jsp page with the correct
 value.
 So it is not an issue with Hibernate but with the jsp or ModelDriven
 interface I don't know..Do you have any idea?
 Basically I was not able to find a struts or spring documentation about
 CRUD
  association between two entities on the same jsp page.
 best regards
 bruno



 --
 From: Rene Gielen
 Sent: Wednesday, March 31, 2010 7:12 PM
 To: Struts Users Mailing List
 Subject: Re: CRUD with a 

Error creating form bean struts 1.2 + weblogic 8.1 + myeclipse 5.5

2010-04-01 Thread Nanu Khota
Hi All,
I am a newbee to struts and trying some hands on it. I was just trying to 
develop a simple login form but getting following exception on initial run only.
-
SEVERE: Error creating form bean of class 
com.abc.struts.form.LoginFormjava.lang.NullPointerExceptionat 
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)at
 org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)at 
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)at 
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:477)at 
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)at 
jsp_servlet.__login._jspService(__login.java:196)at 
weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
-
I tried searching thru all forums from last 2 days but could not found any 
solution to the issue. This seems to be a very common problem but I don't know 
why its not going away. I am really stuck up.
Below are the listing of files required to analyize the cause of error.
web.xmllt;?xml version=1.0 encoding=UTF-8?gt;lt;!DOCTYPE 
web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN 
http://java.sun.com/dtd/web-app_2_3.dtdgt;lt;web-appgt;nbsp; 
lt;servletgt;nbsp;nbsp;nbsp; 
lt;servlet-namegt;actionlt;/servlet-namegt;nbsp;nbsp;nbsp; 
lt;servlet-classgt;org.apache.struts.action.ActionServletlt;/servlet-classgt;nbsp;nbsp;nbsp;
 lt;init-paramgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-namegt;configlt;/param-namegt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-valuegt;/WEB-INF/struts-config.xmllt;/param-valuegt;nbsp;nbsp;nbsp;
 lt;/init-paramgt;nbsp;nbsp;nbsp; 
lt;init-paramgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-namegt;debuglt;/param-namegt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-valuegt;3lt;/param-valuegt;nbsp;nbsp;nbsp; 
lt;/init-paramgt;nbsp;nbsp;nbsp; 
lt;init-paramgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-namegt;detaillt;/param-namegt;nbsp;nbsp;nbsp;
 nbsp;nbsp; lt;param-valuegt;3lt;/param-valuegt;nbsp;nbsp;nbsp; 
lt;/init-paramgt;nbsp;nbsp;nbsp; 
lt;load-on-startupgt;0lt;/load-on-startupgt;nbsp; lt;/servletgt;nbsp; 
lt;servlet-mappinggt;nbsp;nbsp;nbsp; 
lt;servlet-namegt;actionlt;/servlet-namegt;nbsp;nbsp;nbsp; 
lt;url-patterngt;*.dolt;/url-patterngt;nbsp; 
lt;/servlet-mappinggt;nbsp; lt;welcome-file-listgt;nbsp;nbsp;nbsp; 
lt;welcome-filegt;index.jsplt;/welcome-filegt;nbsp; 
lt;/welcome-file-listgt;nbsp; lt;taglibgt;nbsp; 
nbsp;lt;taglib-urigt;/WEB-INF/struts-html.tldlt;/taglib-urigt;nbsp; 
nbsp;lt;taglib-locationgt;/WEB-INF/struts-html.tldlt;/taglib-locationgt;nbsp;
 lt;/taglibgt;lt;/web-appgt;
index.jsp-..lt;bodygt;nbsp;nbsp;nbsp; lt;html:link 
page=/home.dogt;Loginlt;/html:linkgt;nbsp; lt;/bodygt;.
struts-config.xml-lt;?xml version=1.0 
encoding=UTF-8?gt;lt;!DOCTYPE struts-config PUBLIC -//Apache Software 
Foundation//DTD Struts Configuration 1.2//EN 
http://struts.apache.org/dtds/struts-config_1_2.dtdgt;
lt;struts-configgt;nbsp; lt;data-sources /gt;nbsp; lt;form-beans 
gt;nbsp;nbsp;nbsp; lt;form-bean name=loginForm 
type=com.siemens.struts.form.LoginForm /gt;
nbsp; lt;/form-beansgt;
nbsp; lt;global-exceptions /gt;nbsp; lt;global-forwards /gt;nbsp; 
lt;action-mappings gt;nbsp;nbsp;nbsp; 
lt;actionnbsp;nbsp;nbsp;nbsp;nbsp; 
attribute=loginFormnbsp;nbsp;nbsp;nbsp;nbsp; 
name=loginFormnbsp;nbsp;nbsp;nbsp;nbsp; 
path=/empLoginnbsp;nbsp;nbsp;nbsp;nbsp; 
scope=requestnbsp;nbsp;nbsp;nbsp;nbsp; 
type=com.siemens.struts.action.EmpLoginActionnbsp;nbsp;nbsp;nbsp;nbsp; 
validate=false /gt;nbsp;nbsp;nbsp;nbsp;nbsp; nbsp;nbsp;nbsp; 
lt;action forward=/Login.jsp path=/home /gt;
nbsp; lt;/action-mappingsgt;
nbsp; lt;message-resources 
parameter=com.siemens.struts.ApplicationResources /gt;lt;/struts-configgt;
Login.jsp-
lt;bodygt;nbsp;nbsp;nbsp; lt;html:form action=/empLogin method=post 
focus=logingt;nbsp;nbsp;nbsp;nbsp;nbsp; lt;table 
border=0gt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;tdgt;Login:lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 lt;tdgt;lt;html:text property=login 
/gt;lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;/trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;tdgt;Password:lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 lt;tdgt;lt;html:password property=password 
/gt;lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;/trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; lt;td 
colspan=2 
align=centergt;lt;html:submitgt;Loginlt;/html:submitgt;lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbs
 p;nbsp;nbsp; lt;/trgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;/tablegt;nbsp;nbsp;nbsp; lt;/html:formgt;nbsp; lt;/bodygt;
I can also provide the form bean and action class if required but I believe 

Error creating form bean - struts 1.2 + weblogic 8.1 + myeclipse 5.5

2010-04-01 Thread nanukhota
Hi All,
I am a newbee to struts and trying some hands on it. I was just trying to 
develop a simple login form but getting following exception on initial run only.
-
SEVERE: Error creating form bean of class 
com.abc.struts.form.LoginFormjava.lang.NullPointerExceptionat 
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)at
 org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)at 
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)at 
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:477)at 
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)at 
jsp_servlet.__login._jspService(__login.java:196)at 
weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
-
I tried searching thru all forums from last 2 days but could not found any 
solution to the issue. This seems to be a very common problem but I don't know 
why its not going away. I am really stuck up.
Below are the listing of files required to analyize the cause of error.
web.xmlhttp://java.sun.com/dtd/web-app_2_3.dtdgt;actionorg.apache.struts.action.ActionServletconfig/WEB-INF/struts-config.xmldebug3detail30action*.doindex.jsp/WEB-INF/struts-html.tld/WEB-INF/struts-html.tld
index.jsp-..Login.
struts-config.xml-http://struts.apache.org/dtds/struts-config_1_2.dtdgt;




Error creating form bean - struts 1.2 + weblogic 8.1 + myeclipse 5.5

2010-04-01 Thread Vivek Gupta
Hi All,

I am a newbee to struts and trying some hands on it. I was just trying to
develop a simple login form but getting following exception on initial run
only.

-

SEVERE: Error creating form bean of class com.abc.struts.form.LoginForm
java.lang.NullPointerException
at
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)
at
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)
at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:477)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)
at jsp_servlet.__login._jspService(__login.java:196)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)

-

I tried searching thru all forums from last 2 days but could not found any
solution to the issue. This seems to be a very common problem but I don't
know why its not going away. I am really stuck up.

Below are the listing of files required to analyize the cause of error.

web.xml

?xml version=1.0 encoding=UTF-8?
!DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application
2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd;
web-app
  servlet
servlet-nameaction/servlet-name
servlet-classorg.apache.struts.action.ActionServlet/servlet-class
init-param
  param-nameconfig/param-name
  param-value/WEB-INF/struts-config.xml/param-value
/init-param
init-param
  param-namedebug/param-name
  param-value3/param-value
/init-param
init-param
  param-namedetail/param-name
  param-value3/param-value
/init-param
load-on-startup0/load-on-startup
  /servlet
  servlet-mapping
servlet-nameaction/servlet-name
url-pattern*.do/url-pattern
  /servlet-mapping
  welcome-file-list
welcome-fileindex.jsp/welcome-file
  /welcome-file-list
  taglib
   taglib-uri/WEB-INF/struts-html.tld/taglib-uri
   taglib-location/WEB-INF/struts-html.tld/taglib-location
  /taglib
/web-app


index.jsp
-
..
body
html:link page=/home.doLogin/html:link
  /body
.


struts-config.xml
-
?xml version=1.0 encoding=UTF-8?
!DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts
Configuration 1.2//EN http://struts.apache.org/dtds/struts-config_1_2.dtd


struts-config
  data-sources /
  form-beans 
form-bean name=loginForm type=com.siemens.struts.form.LoginForm /

  /form-beans

  global-exceptions /
  global-forwards /
  action-mappings 
action
  attribute=loginForm
  name=loginForm
  path=/empLogin
  scope=request
  type=com.siemens.struts.action.EmpLoginAction
  validate=false /

action forward=/Login.jsp path=/home /

  /action-mappings

  message-resources parameter=com.siemens.struts.ApplicationResources /
/struts-config


Login.jsp
-

body
html:form action=/empLogin method=post focus=login
  table border=0
tr
  tdLogin:/td
  tdhtml:text property=login //td
/tr
tr
  tdPassword:/td
  tdhtml:password property=password //td
/tr
tr
  td colspan=2
align=centerhtml:submitLogin/html:submit/td
/tr
  /table
/html:form
  /body

I can also provide the form bean and action class if required but I believe
it won't add to solving the problem as the exception occurs when I click on
the link on index.jsp and then it tries to render the Login.jsp.

Please help.

Nanu


RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean

thks adam but I got now thousand  thousand of lines

I am afraid that I won't be able to read its before the end of the world in 
2012..

 

I saw very quicky an exception at the beginning.. 

How can I limit this huge quantity of lines?

 

here is my log4j.properties file:

 

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout
log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug

 

 


 
 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:57:39 +0100
 
 
 
 
 in log4j.properties file (same location as struts.xml and hibernate config 
 files)
 
 add
 
 log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug
 
 this will output param name/value pairs being posted from your page.
 
 
 
 
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 13:54:33 +0200
 
 
  Dear Adam,
 
 
 
  I just added a public Child getValues(int idx) in the Parent class 
  definition but it is never called.
 
 
 
  Could u explain to me where and how can I turn on the parameterinterceptor 
  logging? In the struts.xml file?
 
 
 
  thks a lot
 
 
  bruno
 
 
 
 
 
  From: apin...@hotmail.co.uk
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 12:18:48 +0100
 
 
 
 
  turn on the parameterinterceptor logging and make sure as mentioned that
 
  1) the values you expect for each child are being sent to the server (id 
  and name)
  2) the parameter names are correct for setting each child
 
  i had some issues getting lists of items to be updated by form submission 
  alone.
 
  for example does your parent object have a getValues method taking an 
  index value
 
  getParent().getValues(1).setId(1)
  getParent().getValues(1).setName(bob)
 
  would be called by parameterinterceptor
 
 
  
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 
  3
  Date: Thu, 1 Apr 2010 12:16:09 +0200
 
 
  Dear René
 
 
 
  I changed my jsp page so as to integrate the following block:
 
 
 
 
 
 
 
 
 
 
  which generates the following html code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  I can display my complete Child Set but I got the same result after 
  updating: my Child Set is empty.
 
 
 
  Is that necessary to modify my ParentAction as well? If yes what to do?
 
 
 
  public class ParentAction extends ActionSupport implements ModelDriven {
 
  private static final long serialVersionUID = -2662966220408285700L;
  private Parent cl = new Parent();
  private List clList = new ArrayList();
  private ParentDAO clDAO = new ParentDAOImpl();
 
  @Override
  public Parent getModel() {
  return cl;
  }
 
  public String saveOrUpdate()
  { // cl.values is empty here!!
  clDAO.saveOrUpdateParent(cl);
  return SUCCESS;
  }
 
  public String save()
  {
  clDAO.saveParent(cl);
  return SUCCESS;
  }
 
  public String list()
  {
  clList = clDAO.listParent();
  return SUCCESS;
  }
 
  public String delete()
  {
  HttpServletRequest request = (HttpServletRequest) 
  ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
  clDAO.deleteParent(Long.parseLong(request.getParameter(id)));
  return SUCCESS;
  }
 
  public String edit()
  { // cl.values contains some valid Child elements here!!
  HttpServletRequest request = (HttpServletRequest) 
  ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
  cl = clDAO.listParentById(Long.parseLong(request.getParameter(id)));
  }
  return SUCCESS;
  }
 
  public Parent getParent() {
  return cl;
  }
 
  public void setParent(Parent cl) {
  this.cl = cl;
  }
 
  public List getParentList() {
  return clList;
  }
 
  public void setParentList(List clList) {
  this.clList = clList;
  }
  }
 
 
 
  Date: Thu, 1 Apr 2010 11:30:23 +0200
  From: gie...@it-neering.net
  To: user@struts.apache.org
  Subject: Re: CRUD with a OneToMany association under Struts 2 / 
  Hibernate 3
 
  Given the model you presented in the first post, your problem seems to
  be that the posted values have not the correct name for the children's
  form fields. The parameters names you would need are
 
  id
  name
  values[0].id
  values[0].name
  values[1].id
  values[2].name
  ...
 
  for the parameters interceptor to work properly when applying the posted
  values.
 
  See here for more details:
  http://struts.apache.org/2.1.8/docs/tabular-inputs.html
 
  - René
 
  bruno grandjean schrieb:
  Dear Rene,
 
  Thks a 

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread adam pinder

 
set the rootlogger to warn
 
log4j.rootLogger=warn, stdout

rather than debug
 
you should only get a parameterinterceptor log entry every time you post 
something to the server


 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 14:51:40 +0200


 thks adam but I got now thousand  thousand of lines

 I am afraid that I won't be able to read its before the end of the world in 
 2012..



 I saw very quicky an exception at the beginning..

 How can I limit this huge quantity of lines?



 here is my log4j.properties file:



 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.Target=System.out
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - 
 %m%n
 log4j.rootLogger=debug, stdout
 log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug







 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:57:39 +0100




 in log4j.properties file (same location as struts.xml and hibernate config 
 files)

 add

 log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug

 this will output param name/value pairs being posted from your page.



 
 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 13:54:33 +0200


 Dear Adam,



 I just added a public Child getValues(int idx) in the Parent class 
 definition but it is never called.



 Could u explain to me where and how can I turn on the parameterinterceptor 
 logging? In the struts.xml file?



 thks a lot


 bruno





 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:18:48 +0100




 turn on the parameterinterceptor logging and make sure as mentioned that

 1) the values you expect for each child are being sent to the server (id 
 and name)
 2) the parameter names are correct for setting each child

 i had some issues getting lists of items to be updated by form submission 
 alone.

 for example does your parent object have a getValues method taking an 
 index value

 getParent().getValues(1).setId(1)
 getParent().getValues(1).setName(bob)

 would be called by parameterinterceptor


 
 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 
 3
 Date: Thu, 1 Apr 2010 12:16:09 +0200


 Dear René



 I changed my jsp page so as to integrate the following block:










 which generates the following html code:


























 I can display my complete Child Set but I got the same result after 
 updating: my Child Set is empty.



 Is that necessary to modify my ParentAction as well? If yes what to do?



 public class ParentAction extends ActionSupport implements ModelDriven {

 private static final long serialVersionUID = -2662966220408285700L;
 private Parent cl = new Parent();
 private List clList = new ArrayList();
 private ParentDAO clDAO = new ParentDAOImpl();

 @Override
 public Parent getModel() {
 return cl;
 }

 public String saveOrUpdate()
 { // cl.values is empty here!!
 clDAO.saveOrUpdateParent(cl);
 return SUCCESS;
 }

 public String save()
 {
 clDAO.saveParent(cl);
 return SUCCESS;
 }

 public String list()
 {
 clList = clDAO.listParent();
 return SUCCESS;
 }

 public String delete()
 {
 HttpServletRequest request = (HttpServletRequest) 
 ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
 clDAO.deleteParent(Long.parseLong(request.getParameter(id)));
 return SUCCESS;
 }

 public String edit()
 { // cl.values contains some valid Child elements here!!
 HttpServletRequest request = (HttpServletRequest) 
 ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
 cl = clDAO.listParentById(Long.parseLong(request.getParameter(id)));
 }
 return SUCCESS;
 }

 public Parent getParent() {
 return cl;
 }

 public void setParent(Parent cl) {
 this.cl = cl;
 }

 public List getParentList() {
 return clList;
 }

 public void setParentList(List clList) {
 this.clList = clList;
 }
 }



 Date: Thu, 1 Apr 2010 11:30:23 +0200
 From: gie...@it-neering.net
 To: user@struts.apache.org
 Subject: Re: CRUD with a OneToMany association under Struts 2 / 
 Hibernate 3

 Given the model you presented in the first post, your problem seems to
 be that the posted values have not the correct name for the children's
 form fields. The parameters names you would need are

 id
 name
 values[0].id
 values[0].name
 values[1].id
 values[2].name
 ...

 for the parameters interceptor to work 

RE: Error creating form bean struts 1.2 + weblogic 8.1 + myeclipse 5.5

2010-04-01 Thread adam pinder

 
seems like form definition isn't in struts config file or properly defined


 Date: Thu, 1 Apr 2010 11:45:42 +
 To: user@struts.apache.org
 Subject: Error creating form bean struts 1.2 + weblogic 8.1 + myeclipse 5.5
 From: nanukh...@rediffmail.com

 Hi All,
 I am a newbee to struts and trying some hands on it. I was just trying to 
 develop a simple login form but getting following exception on initial run 
 only.
 -
 SEVERE: Error creating form bean of class 
 com.abc.struts.form.LoginFormjava.lang.NullPointerExceptionat 
 org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)at
  
 org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)at 
 org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)at 
 org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:477)at 
 org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)at 
 jsp_servlet.__login._jspService(__login.java:196)at 
 weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
 -
 I tried searching thru all forums from last 2 days but could not found any 
 solution to the issue. This seems to be a very common problem but I don't 
 know why its not going away. I am really stuck up.
 Below are the listing of files required to analyize the cause of error.
 web.xml?xml version=1.0 encoding=UTF-8?!DOCTYPE web-app 
 PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN 
 http://java.sun.com/dtd/web-app_2_3.dtd;web-app  servlet
 servlet-nameaction/servlet-name
 servlet-classorg.apache.struts.action.ActionServlet/servlet-class
 init-param  param-nameconfig/param-name  
 param-value/WEB-INF/struts-config.xml/param-value/init-param
 init-param  param-namedebug/param-name  
 param-value3/param-value/init-paraminit-param  
 param-namedetail/param-name   
 nbsp;  param-value3/param-value/init-param
 load-on-startup0/load-on-startup  /servlet  servlet-mapping
 servlet-nameaction/servlet-nameurl-pattern*.do/url-pattern  
 /servlet-mapping  welcome-file-list
 welcome-fileindex.jsp/welcome-file  /welcome-file-list  taglib   
 taglib-uri/WEB-INF/struts-html.tld/taglib-uri   
 taglib-location/WEB-INF/struts-html.tld/taglib-location  
 /taglib/web-app
 index.jsp-..bodyhtml:link 
 page=/home.doLogin/html:link  /body.
 struts-config.xml-?xml version=1.0 
 encoding=UTF-8?!DOCTYPE struts-config PUBLIC -//Apache Software 
 Foundation//DTD Struts Configuration 1.2//EN 
 http://struts.apache.org/dtds/struts-config_1_2.dtd;
 struts-config  data-sources /  form-beansform-bean 
 name=loginForm type=com.siemens.struts.form.LoginForm /
   /form-beans
   global-exceptions /  global-forwards /  action-mappingsaction
   attribute=loginForm  name=loginForm  path=/empLogin  
 scope=request  type=com.siemens.struts.action.EmpLoginAction  
 validate=false /  action forward=/Login.jsp path=/home /
   /action-mappings
   message-resources parameter=com.siemens.struts.ApplicationResources 
 //struts-config
 Login.jsp-
 bodyhtml:form action=/empLogin method=post focus=login  
 table border=0tr  tdLogin:/td  
 tdhtml:text property=login //td/trtr  
 tdPassword:/td  tdhtml:password property=password //td
 /trtr  td colspan=2 
 align=centerhtml:submitLogin/html:submit/tdnbs
 p;   /tr  /table/html:form  /body
 I can also provide the form bean and action class if required but I believe 
 it won't add to solving the problem as the exception occurs when I click on 
 the link on index.jsp and then it tries to render the Login.jsp.
 Please help.
 Nanu
 
_
Send us your Hotmail stories and be featured in our newsletter
http://clk.atdmt.com/UKM/go/195013117/direct/01/
-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean

Here are exceptions I got after submitting:
 


Entering getProperty()
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.0
...
 


Entering getProperty()
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.0
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
..


Entering getProperty()
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.1
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
..


Entering getProperty()
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.1
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
..



Hibernate Validation in class com.metacrud.web.ParentAction
Hibernate Validation found no erros.
Executing action method = saveOrUpdate
Redirecting to finalLocation /Metacrud/listParent
after Locale=fr
intercept } 
processing flush-time cascades
dirty checking collections
Collection found: [com.metacrud.domain.Parent.values#1], was: [unreferenced] 
(initialized)
Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
Flushed: 1 (re)creations, 0 updates, 1 removals to 1 collections
listing entities:
com.metacrud.domain.Parent{id=1, values=[], name=Parent1}
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
update PARENT set NAME=? where PARENT_ID=?
Executing batch size: 1
about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
Deleting collection: [com.metacrud.domain.Parent.values#1]
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
delete from PARENT_CHILD where PARENT_ID=?
done deleting collection

 

 

 


 
 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:57:39 +0100
 
 
 
 
 in log4j.properties file (same location as struts.xml and hibernate config 
 files)
 
 add
 
 log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug
 
 this will output param name/value pairs being posted from your page.
 
 
 
 
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 13:54:33 +0200
 
 
  Dear Adam,
 
 
 
  I just added a public Child getValues(int idx) in the Parent class 
  definition but it is never called.
 
 
 
  Could u explain to me where and how can I turn on the parameterinterceptor 
  logging? In the struts.xml file?
 
 
 
  thks a lot
 
 
  bruno
 
 
 
 
 
  From: apin...@hotmail.co.uk
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 12:18:48 +0100
 
 
 
 
  turn on the parameterinterceptor logging and make sure as mentioned that
 
  1) the values you expect for each child are being sent to the server (id 
  and name)
  2) the parameter names are correct for setting each child
 
  i had some issues getting lists of items to be updated by form submission 
  alone.
 
  for example does your parent object have a getValues method taking an 
  index value
 
  getParent().getValues(1).setId(1)
  getParent().getValues(1).setName(bob)
 
  would be called by parameterinterceptor
 
 
  
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 
  3
  Date: Thu, 1 Apr 2010 12:16:09 +0200
 
 
  Dear René
 
 
 
  I changed my jsp page so as to integrate the following block:
 
 
 
 
 
 
 
 
 
 
  which generates the following html code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  I can display my complete Child Set but I got the same result after 
  updating: my Child Set is empty.
 
 
 
  Is that necessary to modify my ParentAction as well? If yes what to do?
 
 
 
  public class ParentAction extends ActionSupport implements ModelDriven {
 
  private static final long serialVersionUID = -2662966220408285700L;
  private Parent cl = new Parent();
  private List clList = new ArrayList();
  private ParentDAO clDAO = new ParentDAOImpl();
 
  @Override
  public Parent getModel() {
  return cl;
  }
 
  public String saveOrUpdate()
  { // cl.values is empty here!!
  clDAO.saveOrUpdateParent(cl);
  return SUCCESS;
  }
 
  public String save()
  {
  clDAO.saveParent(cl);
  return SUCCESS;
  }
 
  public String list()
  {
  clList = clDAO.listParent();
  return SUCCESS;
  }
 
  public String delete()
  {
  HttpServletRequest request = (HttpServletRequest) 
  ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
  clDAO.deleteParent(Long.parseLong(request.getParameter(id)));
  return SUCCESS;
  }
 
  public String edit()
  { // cl.values contains some valid Child elements here!!
  HttpServletRequest request = (HttpServletRequest) 
  ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
  cl = 

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean

Thks a lot Adam it is now more concise:

 

Setting params 
Setting params id = [ 1 ] 
Setting params id = [ 1 ] method:saveOrUpdate = [ Submit ] name = [ Parent1 
] parent.values[0].id = [ 2 ] parent.values[0].name = [ Child2 ] 
parent.values[1].id = [ 1 ] parent.values[1].name = [ Child1 ]

 

Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.0
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
at 
com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)
at java.lang.Thread.run(Unknown Source)
..
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.0
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
..
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.1
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
at 
com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)
..
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.1
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
at 
com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)
at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1643)
..
 
Setting params 

Do u see something wrong??

 

 
 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 13:54:58 +0100
 
 
 
 set the rootlogger to warn
 
 log4j.rootLogger=warn, stdout
 
 rather than debug
 
 you should only get a parameterinterceptor log entry every time you post 
 something to the server
 
 
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 14:51:40 +0200
 
 
  thks adam but I got now thousand  thousand of lines
 
  I am afraid that I won't be able to read its before the end of the world in 
  2012..
 
 
 
  I saw very quicky an exception at the beginning..
 
  How can I limit this huge quantity of lines?
 
 
 
  here is my log4j.properties file:
 
 
 
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  log4j.appender.stdout.Target=System.out
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - 
  %m%n
  log4j.rootLogger=debug, stdout
  log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug
 
 
 
 
 
 
 
  From: apin...@hotmail.co.uk
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 12:57:39 +0100
 
 
 
 
  in log4j.properties file (same location as struts.xml and hibernate config 
  files)
 
  add
 
  log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug
 
  this will output param name/value pairs being posted from your page.
 
 
 
  
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 
  3
  Date: Thu, 1 Apr 2010 13:54:33 +0200
 
 
  Dear Adam,
 
 
 
  I just added a public Child getValues(int idx) in the Parent class 
  definition but it is never called.
 
 
 
  Could u explain to me where and how can I turn on the 
  parameterinterceptor logging? In the struts.xml file?
 
 
 
  thks a lot
 
 
  bruno
 
 
 
 
 
  From: apin...@hotmail.co.uk
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / 
  Hibernate 3
  Date: Thu, 1 Apr 2010 12:18:48 +0100
 
 
 
 
  turn on the parameterinterceptor logging and make sure as mentioned that
 
  1) the values you expect for each child are being sent to the server (id 
  and name)
  2) the parameter names are correct for setting each child
 
  i had some issues getting lists of items to be updated by form 
  submission alone.
 
  for example does your parent object have a getValues method taking an 
  index value
 
  getParent().getValues(1).setId(1)
  getParent().getValues(1).setName(bob)
 
  would be called by parameterinterceptor
 
 
  
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / 
  Hibernate 3
  Date: Thu, 1 Apr 2010 12:16:09 +0200
 
 
  Dear René
 
 
 
  I changed my jsp page so as to integrate the following block:
 
 
 
 
 
 
 
 
 
 
  which generates the following html code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  I can display my complete Child Set but I got the same result after 
  updating: my Child Set is empty.
 
 
 
  Is that necessary to modify my ParentAction as well? If yes what to do?
 
 
 
  public class ParentAction extends ActionSupport implements ModelDriven 

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean

Here is my Child class definition:

@Entity
@Table(name=CHILD)
public class Child {
private Long id; 
private String name; 
@Id
@GeneratedValue
@Column(name=CHILD_ID) 
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name=NAME)
public String getName() { 
return name;
}
public void setName(String val) {
name = val;
} 
}

 

and Parent definition:

@Entity
@Table(name=PARENT)
public class Parent {
private Long id;
private String name;
private SetChild values = new HashSetChild(); 
@Id
@GeneratedValue
@Column(name=PARENT_ID) 
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Column(name=NAME)
public String getName() { 
return name;
}
public void setName(String val) {
name = val;
} 
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) 
@JoinTable(name = PARENT_CHILD, joinColumns = { @JoinColumn(name = 
PARENT_ID) }, inverseJoinColumns = { @JoinColumn(name = CHILD_ID) }) 
public SetChild getValues() { 
return values;
}
public Child getValues(Long idx) { // NEVER CALLED!
for ( IteratorChild iter = values.iterator(); iter.hasNext();) {
Child c = (Child) iter.next(); 
if (c.getId() == idx) return c;
} 
return null;
}
public void setValues(SetChild lst) {
values = lst; 
}
}

 

So I do not understand the ognl.NoSuchPropertyException I got after submission..


 
 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 13:54:58 +0100
 
 
 
 set the rootlogger to warn
 
 log4j.rootLogger=warn, stdout
 
 rather than debug
 
 you should only get a parameterinterceptor log entry every time you post 
 something to the server
 
 
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 14:51:40 +0200
 
 
  thks adam but I got now thousand  thousand of lines
 
  I am afraid that I won't be able to read its before the end of the world in 
  2012..
 
 
 
  I saw very quicky an exception at the beginning..
 
  How can I limit this huge quantity of lines?
 
 
 
  here is my log4j.properties file:
 
 
 
  log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  log4j.appender.stdout.Target=System.out
  log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - 
  %m%n
  log4j.rootLogger=debug, stdout
  log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug
 
 
 
 
 
 
 
  From: apin...@hotmail.co.uk
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
  Date: Thu, 1 Apr 2010 12:57:39 +0100
 
 
 
 
  in log4j.properties file (same location as struts.xml and hibernate config 
  files)
 
  add
 
  log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug
 
  this will output param name/value pairs being posted from your page.
 
 
 
  
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 
  3
  Date: Thu, 1 Apr 2010 13:54:33 +0200
 
 
  Dear Adam,
 
 
 
  I just added a public Child getValues(int idx) in the Parent class 
  definition but it is never called.
 
 
 
  Could u explain to me where and how can I turn on the 
  parameterinterceptor logging? In the struts.xml file?
 
 
 
  thks a lot
 
 
  bruno
 
 
 
 
 
  From: apin...@hotmail.co.uk
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / 
  Hibernate 3
  Date: Thu, 1 Apr 2010 12:18:48 +0100
 
 
 
 
  turn on the parameterinterceptor logging and make sure as mentioned that
 
  1) the values you expect for each child are being sent to the server (id 
  and name)
  2) the parameter names are correct for setting each child
 
  i had some issues getting lists of items to be updated by form 
  submission alone.
 
  for example does your parent object have a getValues method taking an 
  index value
 
  getParent().getValues(1).setId(1)
  getParent().getValues(1).setName(bob)
 
  would be called by parameterinterceptor
 
 
  
  From: brgrandj...@live.fr
  To: user@struts.apache.org
  Subject: RE: CRUD with a OneToMany association under Struts 2 / 
  Hibernate 3
  Date: Thu, 1 Apr 2010 12:16:09 +0200
 
 
  Dear René
 
 
 
  I changed my jsp page so as to integrate the following block:
 
 
 
 
 
 
 
 
 
 
  which generates the following html code:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  I can display my complete Child Set but I got the same result after 
  updating: my Child Set is empty.
 
 
 
  Is that necessary to modify my ParentAction as well? If yes what to do?
 
 
 
  public class ParentAction extends ActionSupport implements ModelDriven {
 
  private static final long 

RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread adam pinder

 
so it looks like your issue is more to do with the child values not being set 
by Struts
 
there have been a few postings about using the [] notation on field names to 
get struts to assign the values properly.
 
in struts1 i found it worked fine, however in struts2 i've not really seen it 
working... in some of my actions i have actually added a method which gets the 
parameter values off the request and populates the objects myself..
 
e.g. look for parameter names starting parent.values and use the parameter 
name/value to construct the correct call to set the object.
 
seems unnecessary as struts2 should handle it, but as i say i couldn't get it 
to do it with arraylists i was using.
 



 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 15:16:36 +0200


 Thks a lot Adam it is now more concise:



 Setting params
 Setting params id = [ 1 ]
 Setting params id = [ 1 ] method:saveOrUpdate = [ Submit ] name = [ 
 Parent1 ] parent.values[0].id = [ 2 ] parent.values[0].name = [ Child2 ] 
 parent.values[1].id = [ 1 ] parent.values[1].name = [ Child1 ]



 Error setting value
 ognl.NoSuchPropertyException: java.util.HashSet.0
 at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
 at 
 com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)
 at java.lang.Thread.run(Unknown Source)
 ..
 Error setting value
 ognl.NoSuchPropertyException: java.util.HashSet.0
 at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
 ..
 Error setting value
 ognl.NoSuchPropertyException: java.util.HashSet.1
 at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
 at 
 com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)
 ..
 Error setting value
 ognl.NoSuchPropertyException: java.util.HashSet.1
 at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
 at 
 com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)
 at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1643)
 ..

 Setting params

 Do u see something wrong??




 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 13:54:58 +0100



 set the rootlogger to warn

 log4j.rootLogger=warn, stdout

 rather than debug

 you should only get a parameterinterceptor log entry every time you post 
 something to the server

 
 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 14:51:40 +0200


 thks adam but I got now thousand  thousand of lines

 I am afraid that I won't be able to read its before the end of the world in 
 2012..



 I saw very quicky an exception at the beginning..

 How can I limit this huge quantity of lines?



 here is my log4j.properties file:



 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.Target=System.out
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - 
 %m%n
 log4j.rootLogger=debug, stdout
 log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug







 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3
 Date: Thu, 1 Apr 2010 12:57:39 +0100




 in log4j.properties file (same location as struts.xml and hibernate config 
 files)

 add

 log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug

 this will output param name/value pairs being posted from your page.



 
 From: brgrandj...@live.fr
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 
 3
 Date: Thu, 1 Apr 2010 13:54:33 +0200


 Dear Adam,



 I just added a public Child getValues(int idx) in the Parent class 
 definition but it is never called.



 Could u explain to me where and how can I turn on the 
 parameterinterceptor logging? In the struts.xml file?



 thks a lot


 bruno





 From: apin...@hotmail.co.uk
 To: user@struts.apache.org
 Subject: RE: CRUD with a OneToMany association under Struts 2 / 
 Hibernate 3
 Date: Thu, 1 Apr 2010 12:18:48 +0100




 turn on the parameterinterceptor logging and make sure as mentioned that

 1) the values you expect for each child are being sent to the server (id 
 and name)
 2) the parameter names are correct for setting each child

 i had some issues getting lists of items to be updated by form 
 submission alone.

 for example does your parent object have a getValues method taking an 

SImple question on bypassing prepare

2010-04-01 Thread jayakumar ala
Hi All,
 I am new to struts2 and need small help on how i can bypass calling prepare
method before any other method. In my case i am trying to call customized
method before prepare method to set some values. I did set method in my
struts.xml but it is still calling prepare(). I want this prepare to be
called after calling my customized method.
Any help is appreciated.

Thanks


int's and OGNL in struts.xml

2010-04-01 Thread Chris Pratt
I'm trying to use the OGNL support in Struts 2.0.14 to set some parameter
values in the jFreeChart plugin's chart result type.  But I keep getting
errors because it appears to be expecting all properties to be Strings, even
if the OGNL doesn't return a String.  I'm using:

action name=chart-frame-selection-rate
class=com.vsp.global.controller.ChartFrameSelectionRateAction
  param name=roleuser/param
  result type=chart
param 
name=width$...@com.example.config@getInt(reports,frameSelectionRate.width)}/param
param 
name=height$...@com.example.config@getInt(reports,frameSelectionRate.height)}/param
  /result
  result name=failure type=httpheader404/result
/action

Where

where com.example.Config.getInt is defined as

public int getInt (String domain,String key);


But when struts tries to instantiate the result I get:

[2010-04-01 10:46:57,785] ERROR {abcOu3jlPU3Rf_9tFPSzs}
DefaultActionInvocation.createResult: There was an exception while
instantiating the result of type org.apache.struts2.dispatcher.ChartResult
Caught OgnlException while setting property 'width' on type
'org.apache.struts2.dispatcher.ChartResult'. - Class: ognl.OgnlRuntime
File: OgnlRuntime.java
Method: callAppropriateMethod
Line: 1206 - ognl/OgnlRuntime.java:1206:-1
at
com.opensymphony.xwork2.util.OgnlUtil.internalSetProperty(OgnlUtil.java:367)
at com.opensymphony.xwork2.util.OgnlUtil.setProperties(OgnlUtil.java:76)
  .
  .
  .
Caused by: java.lang.NoSuchMethodException:
org.apache.struts2.dispatcher.ChartResult.setWidth(java.lang.String)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
at
ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
at
ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)


Is there any way to make struts recognize that the value is an int, so it
needs to call setWidth(int)?
  (*Chris*)


Re: SImple question on bypassing prepare

2010-04-01 Thread Chris Pratt
What is it that calls your customized set method?  If it's form parameter
data, move the prepare interceptor below the params interceptor in your
interceptor stack.
  (*Chris*)

On Thu, Apr 1, 2010 at 11:04 AM, jayakumar ala alajay...@gmail.com wrote:

 Hi All,
  I am new to struts2 and need small help on how i can bypass calling
 prepare
 method before any other method. In my case i am trying to call customized
 method before prepare method to set some values. I did set method in my
 struts.xml but it is still calling prepare(). I want this prepare to be
 called after calling my customized method.
 Any help is appreciated.

 Thanks



Error creating form bean - nullpointerexception - struts 1.2 + weblogic 8.1 + myeclipse 5.5

2010-04-01 Thread Nanu Khota
Hi All,
I am a newbee to struts and trying some hands on it. I was just trying to 
develop a simple login form but getting following exception on initial run 
itself.
-
SEVERE: Error creating form bean of class 
com.abc.struts.form.LoginFormjava.lang.NullPointerExceptionat 
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)at
 org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)at 
org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)at 
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:477)at 
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)at 
jsp_servlet.__login._jspService(__login.java:196)at 
weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
-
I tried searching thru all forums from last 2 days but could not found any 
solution to the issue. This seems to be a very common problem but I don't know 
why its not going away. I am really stuck up.
Below are the listing of files required to analyize the cause of error.
web.xmllt;?xml version=1.0 encoding=UTF-8?gt;lt;!DOCTYPE 
web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN 
http://java.sun.com/dtd/web-app_2_3.dtdgt;lt;web-appgt;nbsp; 
lt;servletgt;nbsp;nbsp;nbsp; 
lt;servlet-namegt;actionlt;/servlet-namegt;nbsp;nbsp;nbsp; 
lt;servlet-classgt;org.apache.struts.action.ActionServletlt;/servlet-classgt;nbsp;nbsp;nbsp;
 lt;init-paramgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-namegt;configlt;/param-namegt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-valuegt;/WEB-INF/struts-config.xmllt;/param-valuegt;nbsp;nbsp;nbsp;
 lt;/init-paramgt;nbsp;nbsp;nbsp; 
lt;init-paramgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-namegt;debuglt;/param-namegt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-valuegt;3lt;/param-valuegt;nbsp;nbsp;nbsp; 
lt;/init-paramgt;nbsp;nbsp;nbsp; 
lt;init-paramgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;param-namegt;detaillt;/param-namegt;nbsp;nbsp;nbsp;
 nbsp;nbsp; lt;param-valuegt;3lt;/param-valuegt;nbsp;nbsp;nbsp; 
lt;/init-paramgt;nbsp;nbsp;nbsp; 
lt;load-on-startupgt;0lt;/load-on-startupgt;nbsp; lt;/servletgt;nbsp; 
lt;servlet-mappinggt;nbsp;nbsp;nbsp; 
lt;servlet-namegt;actionlt;/servlet-namegt;nbsp;nbsp;nbsp; 
lt;url-patterngt;*.dolt;/url-patterngt;nbsp; 
lt;/servlet-mappinggt;nbsp; lt;welcome-file-listgt;nbsp;nbsp;nbsp; 
lt;welcome-filegt;index.jsplt;/welcome-filegt;nbsp; 
lt;/welcome-file-listgt;nbsp; lt;taglibgt;nbsp; 
nbsp;lt;taglib-urigt;/WEB-INF/struts-html.tldlt;/taglib-urigt;nbsp; 
nbsp;lt;taglib-locationgt;/WEB-INF/struts-html.tldlt;/taglib-locationgt;nbsp;
 lt;/taglibgt;lt;/web-appgt;
index.jsp-..lt;bodygt;nbsp;nbsp;nbsp; lt;html:link 
page=/home.dogt;Loginlt;/html:linkgt;nbsp; lt;/bodygt;.
struts-config.xml-lt;?xml version=1.0 
encoding=UTF-8?gt;lt;!DOCTYPE struts-config PUBLIC -//Apache Software 
Foundation//DTD Struts Configuration 1.2//EN 
http://struts.apache.org/dtds/struts-config_1_2.dtdgt;
lt;struts-configgt;nbsp; lt;data-sources /gt;nbsp; lt;form-beans 
gt;nbsp;nbsp;nbsp; lt;form-bean name=loginForm 
type=com.siemens.struts.form.LoginForm /gt;
nbsp; lt;/form-beansgt;
nbsp; lt;global-exceptions /gt;nbsp; lt;global-forwards /gt;nbsp; 
lt;action-mappings gt;nbsp;nbsp;nbsp; 
lt;actionnbsp;nbsp;nbsp;nbsp;nbsp; 
attribute=loginFormnbsp;nbsp;nbsp;nbsp;nbsp; 
name=loginFormnbsp;nbsp;nbsp;nbsp;nbsp; 
path=/empLoginnbsp;nbsp;nbsp;nbsp;nbsp; 
scope=requestnbsp;nbsp;nbsp;nbsp;nbsp; 
type=com.siemens.struts.action.EmpLoginActionnbsp;nbsp;nbsp;nbsp;nbsp; 
validate=false /gt;nbsp;nbsp;nbsp;nbsp;nbsp; nbsp;nbsp;nbsp; 
lt;action forward=/Login.jsp path=/home /gt;
nbsp; lt;/action-mappingsgt;
nbsp; lt;message-resources 
parameter=com.siemens.struts.ApplicationResources /gt;lt;/struts-configgt;
Login.jsp-
lt;bodygt;nbsp;nbsp;nbsp; lt;html:form action=/empLogin method=post 
focus=logingt;nbsp;nbsp;nbsp;nbsp;nbsp; lt;table 
border=0gt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;tdgt;Login:lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 lt;tdgt;lt;html:text property=login 
/gt;lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;/trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;tdgt;Password:lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;
 lt;tdgt;lt;html:password property=password 
/gt;lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;/trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;trgt;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; lt;td 
colspan=2 
align=centergt;lt;html:submitgt;Loginlt;/html:submitgt;lt;/tdgt;nbsp;nbsp;nbsp;nbsp;nbs
 p;nbsp;nbsp; lt;/trgt;nbsp;nbsp;nbsp;nbsp;nbsp; 
lt;/tablegt;nbsp;nbsp;nbsp; lt;/html:formgt;nbsp; lt;/bodygt;
I can also provide the form bean and action class if required but I 

Error creating form bean - struts 1.2 + weblogic 8.1 + myeclipse 5.5

2010-04-01 Thread Nanu Khota
---BeginMessage---

Hi All,

I am a newbee to struts and trying some hands on it. I was just trying to 
develop a simple login form but getting following exception on initial run only.

-

SEVERE: Error creating form bean of class com.abc.struts.form.LoginForm
java.lang.NullPointerException
at 
org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:212)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)
at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)
at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:477)
at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)
at jsp_servlet.__login._jspService(__login.java:196)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)

-

I tried searching thru all forums from last 2 days but could not found any 
solution to the issue. This seems to be a very common problem but I don't know 
why its not going away. I am really stuck up.

Below are the listing of files required to analyize the cause of error.

web.xml

?xml version=1.0 encoding=UTF-8?
!DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 
2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd;
web-app
  servlet
servlet-nameaction/servlet-name
servlet-classorg.apache.struts.action.ActionServlet/servlet-class
init-param
  param-nameconfig/param-name
  param-value/WEB-INF/struts-config.xml/param-value
/init-param
init-param
  param-namedebug/param-name
  param-value3/param-value
/init-param
init-param
  param-namedetail/param-name
  param-value3/param-value
/init-param
load-on-startup0/load-on-startup
  /servlet
  servlet-mapping
servlet-nameaction/servlet-name
url-pattern*.do/url-pattern
  /servlet-mapping
  welcome-file-list
welcome-fileindex.jsp/welcome-file
  /welcome-file-list
  taglib
taglib-uri/WEB-INF/struts-html.tld/taglib-uri
taglib-location/WEB-INF/struts-html.tld/taglib-location
  /taglib
/web-app


index.jsp
-
..
body
html:link page=/home.doLogin/html:link
  /body
.


struts-config.xml
-
?xml version=1.0 encoding=UTF-8?
!DOCTYPE struts-config PUBLIC -//Apache Software Foundation//DTD Struts 
Configuration 1.2//EN http://struts.apache.org/dtds/struts-config_1_2.dtd;

struts-config
  data-sources /
  form-beans 
form-bean name=loginForm type=com.siemens.struts.form.LoginForm /

  /form-beans

  global-exceptions /
  global-forwards /
  action-mappings 
action
  attribute=loginForm
  name=loginForm
  path=/empLogin
  scope=request
  type=com.siemens.struts.action.EmpLoginAction
  validate=false /

action forward=/Login.jsp path=/home /

  /action-mappings

  message-resources parameter=com.siemens.struts.ApplicationResources /
/struts-config


Login.jsp
-

body
html:form action=/empLogin method=post focus=login
  table border=0
tr
  tdLogin:/td
  tdhtml:text property=login //td
/tr
tr
  tdPassword:/td
  tdhtml:password property=password //td
/tr
tr
  td colspan=2 align=centerhtml:submitLogin/html:submit/td
/tr
  /table
/html:form
  /body

I can also provide the form bean and action class if required but I believe it 
won't add to solving the problem as the exception occurs when I click on the 
link on index.jsp and then it tries to render the Login.jsp.

Please help.

Nanu


Important notice: This e-mail and any attachment there to contains corporate 
proprietary information. If you have received it by mistake, please notify us 
immediately by reply e-mail and delete this e-mail and its attachments from 
your system.
Thank You.
---End Message---

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Updating a list of objects.

2010-04-01 Thread Andreas Prudzilko

Hi,
I have quite complex object conversions in my actions. I usually convert 
a JSON object to a struts form that I send to an action.

ListTagSet tagSetList;
Where TagSet has own List of Tags for example.

tagSetList = [{name:'ts1', tags: [{name: t1},{name: t2},{name: 
t3}]},{name:'ts1', tags: [{name: t1},{name: t2},{name: t3}]}]

this is then converted to a form format.

tagSetList[0].name=ts1tagSetList[0].tags[0].name=t1tagSetList[0].tags[1].name=t1...

and so on.
This works really great however now I have a problem in the update 
entities case. If it was only one domain object I could go with and 
tagSetId parameter and a prepare method.
However in my scenario I need to intercept when setId() called so I can 
load the persistent state first, before applying my changes.


Any ideas how to do this?
I was thinking I could maybe reuse the params interceptor to set only 
*.id values, but then I would somehow need to know which objects got id 
set, so I can load them.
This all seems very much like a hack. Is there some mechanism to 
intercept setting a primary key?


Ideas and suggestions are welcome!
/Andreas

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: CRUD with a OneToMany association under Struts 2 / Hibernate 3

2010-04-01 Thread bruno grandjean
In all cases, thks a lot for helping me because I was absolutely unable to 
find a solution.
I will try to test what u suggest but I must admit that I am a little bit 
frustrated and disappointed with the ModelDriven interface.
I am also trying to do the same thing with Spring, I hope to be more lucky 
;-)

bruno


--
From: adam pinder apin...@hotmail.co.uk
Sent: Thursday, April 01, 2010 6:19 PM
To: user@struts.apache.org
Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 3




so it looks like your issue is more to do with the child values not being 
set by Struts


there have been a few postings about using the [] notation on field names 
to get struts to assign the values properly.


in struts1 i found it worked fine, however in struts2 i've not really seen 
it working... in some of my actions i have actually added a method which 
gets the parameter values off the request and populates the objects 
myself..


e.g. look for parameter names starting parent.values and use the parameter 
name/value to construct the correct call to set the object.


seems unnecessary as struts2 should handle it, but as i say i couldn't get 
it to do it with arraylists i was using.






From: brgrandj...@live.fr
To: user@struts.apache.org
Subject: RE: CRUD with a OneToMany association under Struts 2 / Hibernate 
3

Date: Thu, 1 Apr 2010 15:16:36 +0200


Thks a lot Adam it is now more concise:



Setting params
Setting params id = [ 1 ]
Setting params id = [ 1 ] method:saveOrUpdate = [ Submit ] name = [ 
Parent1 ] parent.values[0].id = [ 2 ] parent.values[0].name = [ 
Child2 ] parent.values[1].id = [ 1 ] parent.values[1].name = [ Child1 ]




Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.0
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
at 
com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)

at java.lang.Thread.run(Unknown Source)
..
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.0
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
..
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.1
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
at 
com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)

..
Error setting value
ognl.NoSuchPropertyException: java.util.HashSet.1
at ognl.SetPropertyAccessor.getProperty(SetPropertyAccessor.java:67)
at 
com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:80)

at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1643)
..

Setting params

Do u see something wrong??





From: apin...@hotmail.co.uk
To: user@struts.apache.org
Subject: RE: CRUD with a OneToMany association under Struts 2 / 
Hibernate 3

Date: Thu, 1 Apr 2010 13:54:58 +0100



set the rootlogger to warn

log4j.rootLogger=warn, stdout

rather than debug

you should only get a parameterinterceptor log entry every time you post 
something to the server




From: brgrandj...@live.fr
To: user@struts.apache.org
Subject: RE: CRUD with a OneToMany association under Struts 2 / 
Hibernate 3

Date: Thu, 1 Apr 2010 14:51:40 +0200


thks adam but I got now thousand  thousand of lines

I am afraid that I won't be able to read its before the end of the 
world in 2012..




I saw very quicky an exception at the beginning..

How can I limit this huge quantity of lines?



here is my log4j.properties file:



log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p 
%c{1}:%L - %m%n

log4j.rootLogger=debug, stdout
log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug








From: apin...@hotmail.co.uk
To: user@struts.apache.org
Subject: RE: CRUD with a OneToMany association under Struts 2 / 
Hibernate 3

Date: Thu, 1 Apr 2010 12:57:39 +0100




in log4j.properties file (same location as struts.xml and hibernate 
config files)


add

log4j.logger.com.opensymphony.xwork2.interceptor.ParametersInterceptor=debug

this will output param name/value pairs being posted from your page.





From: brgrandj...@live.fr
To: user@struts.apache.org
Subject: RE: CRUD with a OneToMany association under Struts 2 / 
Hibernate 3

Date: Thu, 1 Apr 2010 13:54:33 +0200


Dear Adam,



I just added a public Child getValues(int idx) in the Parent class 
definition but it is never called.




Could u explain to me where and how can I turn on the 
parameterinterceptor logging? In the struts.xml file?




thks a lot


bruno






From: apin...@hotmail.co.uk
To: user@struts.apache.org

RE: SImple question on bypassing prepare

2010-04-01 Thread Kawczynski, David
Extend ActionSupport or one of its subclasses, override the 
prepare( ) method, to call your customized method, then call
super.prepare( ).

 -Original Message-
 From: jayakumar ala [mailto:alajay...@gmail.com] 
 Sent: Thursday, April 01, 2010 2:05 PM
 To: Struts Users Mailing List
 Subject: SImple question on bypassing prepare
 
 Hi All,
  I am new to struts2 and need small help on how i can bypass 
 calling prepare
 method before any other method. In my case i am trying to 
 call customized
 method before prepare method to set some values. I did set 
 method in my
 struts.xml but it is still calling prepare(). I want this 
 prepare to be
 called after calling my customized method.
 Any help is appreciated.
 
 Thanks
 
Notice:  This e-mail message, together with any attachments, contains 
information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station, New 
Jersey, USA 08889), and/or its affiliates Direct contact information for 
affiliates is available at http://www.merck.com/contact/contacts.html) that may 
be confidential, proprietary copyrighted and/or legally privileged. It is 
intended solely for the use of the individual or entity named on this message. 
If you are not the intended recipient, and have received this message in error, 
please notify us immediately by reply e-mail and then delete it from your 
system.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: SImple question on bypassing prepare

2010-04-01 Thread jayakumar ala
Thanks... I got to know how to handle this.

On Thu, Apr 1, 2010 at 1:21 PM, Kawczynski, David 
david_kawczyn...@merck.com wrote:

 Extend ActionSupport or one of its subclasses, override the
 prepare( ) method, to call your customized method, then call
 super.prepare( ).

  -Original Message-
  From: jayakumar ala [mailto:alajay...@gmail.com]
  Sent: Thursday, April 01, 2010 2:05 PM
  To: Struts Users Mailing List
  Subject: SImple question on bypassing prepare
 
  Hi All,
   I am new to struts2 and need small help on how i can bypass
  calling prepare
  method before any other method. In my case i am trying to
  call customized
  method before prepare method to set some values. I did set
  method in my
  struts.xml but it is still calling prepare(). I want this
  prepare to be
  called after calling my customized method.
  Any help is appreciated.
 
  Thanks
 
 Notice:  This e-mail message, together with any attachments, contains
 information of Merck  Co., Inc. (One Merck Drive, Whitehouse Station, New
 Jersey, USA 08889), and/or its affiliates Direct contact information for
 affiliates is available at http://www.merck.com/contact/contacts.html)
 that may be confidential, proprietary copyrighted and/or legally privileged.
 It is intended solely for the use of the individual or entity named on this
 message. If you are not the intended recipient, and have received this
 message in error, please notify us immediately by reply e-mail and then
 delete it from your system.


 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




Nested tiles question

2010-04-01 Thread Subir Kumar
Hi guys,

This is a question for Struts Tiles group.

I've created more than one layout JSP for the site as there are more that one 
layout for the site. But I also want to have kind of a parent layout JSP which 
has references to all global resources - like javascript files etc. How can 
this be achieved? I tried following, but it did not work, while JSPs are 
displayed fine I cannot access javascript functions from the base layout

tiles-definitions

    definition name=base.layout 
path=/Madisons/StoreInfoArea/BaseLayout.jsp/
   
    definition name=myaccount.layout 
path=/Madisons/StoreInfoArea/MyAccountLayout.jsp extends=base.layout
  put name=header 
value=/Madisons/include/styles/default/CachedHeaderDisplay.jsp/
  put name=leftnav 
value=/Madisons/include/styles/default/CachedLeftSidebarDisplay.jsp/
    put name=footer 
value=/Madisons/include/styles/default/CachedFooterDisplay.jsp/   
    /definition
   
    definition name=Madisons.myaccount.shipping.page 
extends=myaccount.layout
 put name=body value=/Madisons/include/home/MyAccountShipping.jsp/
    /definition
   
    definition name=checkout.layout 
path=/Madisons/StoreInfoArea/CheckoutLayout.jsp extends=base.layout
  put name=header 
value=/Madisons/include/styles/default/CachedHeaderDisplay.jsp/
    put name=footer 
value=/Madisons/include/styles/default/CachedFooterDisplay.jsp/   
    /definition
   
    definition name=Madisons.checkout.shipping.page 
extends=checkout.layout
 put name=body value=/Madisons/include/home/CheckoutShipping.jsp/
    /definition   

/tiles-definitions

Thanks,
Subir.



  

RE: int's and OGNL in struts.xml

2010-04-01 Thread Martin Gainty

you can get/string widths with struts-2.1.8 ChartResult

 

public String getWidth() {
return width;
}

public void setWidth(String width) {
this.width = width;
}

 

http://struts.apache.org/download.cgi

hth
Martin Gainty 
__ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger 
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung 
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem 
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. 
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung 
fuer den Inhalt uebernehmen.

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le 
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez 
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est 
interdite. Ce message sert à l'information seulement et n'aura pas n'importe 
quel effet légalement obligatoire. Étant donné que les email peuvent facilement 
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité 
pour le contenu fourni.



 

 Date: Thu, 1 Apr 2010 11:07:34 -0700
 Subject: int's and OGNL in struts.xml
 From: thechrispr...@gmail.com
 To: user@struts.apache.org
 
 I'm trying to use the OGNL support in Struts 2.0.14 to set some parameter
 values in the jFreeChart plugin's chart result type. But I keep getting
 errors because it appears to be expecting all properties to be Strings, even
 if the OGNL doesn't return a String. I'm using:
 
 action name=chart-frame-selection-rate
 class=com.vsp.global.controller.ChartFrameSelectionRateAction
 param name=roleuser/param
 result type=chart
 param 
 name=width$...@com.example.config@getInt(reports,frameSelectionRate.width)}/param
 param 
 name=height$...@com.example.config@getInt(reports,frameSelectionRate.height)}/param
 /result
 result name=failure type=httpheader404/result
 /action
 
 Where
 
 where com.example.Config.getInt is defined as
 
 public int getInt (String domain,String key);
 
 
 But when struts tries to instantiate the result I get:
 
 [2010-04-01 10:46:57,785] ERROR {abcOu3jlPU3Rf_9tFPSzs}
 DefaultActionInvocation.createResult: There was an exception while
 instantiating the result of type org.apache.struts2.dispatcher.ChartResult
 Caught OgnlException while setting property 'width' on type
 'org.apache.struts2.dispatcher.ChartResult'. - Class: ognl.OgnlRuntime
 File: OgnlRuntime.java
 Method: callAppropriateMethod
 Line: 1206 - ognl/OgnlRuntime.java:1206:-1
 at
 com.opensymphony.xwork2.util.OgnlUtil.internalSetProperty(OgnlUtil.java:367)
 at com.opensymphony.xwork2.util.OgnlUtil.setProperties(OgnlUtil.java:76)
 .
 .
 .
 Caused by: java.lang.NoSuchMethodException:
 org.apache.struts2.dispatcher.ChartResult.setWidth(java.lang.String)
 at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
 at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
 at
 ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
 at
 ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
 
 
 Is there any way to make struts recognize that the value is an int, so it
 needs to call setWidth(int)?
 (*Chris*)
  
_
Hotmail has tools for the New Busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_1

Generics and custom Type Converter (Struts 2.1.8)

2010-04-01 Thread Sundar Sankar
Hi
I had a weird problem earlier where, if my pojo had a variable of type
Date, struts was looking for setVariable(String) instead of a
setVariable(Date) for browser locale = es_Cl. I wrote a custom type handler
to solve this problem. Now am stuck with the same problem where I have a
listObject into which Struts needs to set the date.

From the documentation, I added the Element_variable, KeyProperty_variable
and CreatIfNUll_variable, variable=Custom Type Handler into my property
file. This is what happens

1. ) Struts by defaults looks for convertToString method in my converter
class.
2.) When i set my debug, the setVariable is first called and then is the
converter invoked. To solve problem1, I added convertValue and made it
madatorily convert it to date and return that instead of a string. Even
after that, Struts seems to be setting into an instance that isn't what is
in the action class.

As usual, this behaviour is just happening for es_CL locale on my browser
and not when the browser locale is  en_US.

Any help is much appreciated.

-- 
Regards
Sundar S.


Re: int's and OGNL in struts.xml

2010-04-01 Thread Chris Pratt
Unfortunately, we're not up to 2.1.8 yet.  And this really struck me as more
of an OGNL problem of not being able to pass on an int as an int than a
plugin problem.
  (*Chris*)

On Thu, Apr 1, 2010 at 2:29 PM, Martin Gainty mgai...@hotmail.com wrote:


 you can get/string widths with struts-2.1.8 ChartResult



public String getWidth() {
return width;
}

public void setWidth(String width) {
this.width = width;
}



 http://struts.apache.org/download.cgi

 hth
 Martin Gainty
 __
 Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
 Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
 Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
 dient lediglich dem Austausch von Informationen und entfaltet keine
 rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
 E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.

 Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
 destinataire prévu, nous te demandons avec bonté que pour satisfaire
 informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
 de ceci est interdite. Ce message sert à l'information seulement et n'aura
 pas n'importe quel effet légalement obligatoire. Étant donné que les email
 peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
 aucune responsabilité pour le contenu fourni.





  Date: Thu, 1 Apr 2010 11:07:34 -0700
  Subject: int's and OGNL in struts.xml
  From: thechrispr...@gmail.com
  To: user@struts.apache.org
 
  I'm trying to use the OGNL support in Struts 2.0.14 to set some parameter
  values in the jFreeChart plugin's chart result type. But I keep getting
  errors because it appears to be expecting all properties to be Strings,
 even
  if the OGNL doesn't return a String. I'm using:
 
  action name=chart-frame-selection-rate
  class=com.vsp.global.controller.ChartFrameSelectionRateAction
  param name=roleuser/param
  result type=chart
  param name=width$...@com.example.config@getInt
 (reports,frameSelectionRate.width)}/param
  param name=height$...@com.example.config@getInt
 (reports,frameSelectionRate.height)}/param
  /result
  result name=failure type=httpheader404/result
  /action
 
  Where
 
  where com.example.Config.getInt is defined as
 
  public int getInt (String domain,String key);
 
 
  But when struts tries to instantiate the result I get:
 
  [2010-04-01 10:46:57,785] ERROR {abcOu3jlPU3Rf_9tFPSzs}
  DefaultActionInvocation.createResult: There was an exception while
  instantiating the result of type
 org.apache.struts2.dispatcher.ChartResult
  Caught OgnlException while setting property 'width' on type
  'org.apache.struts2.dispatcher.ChartResult'. - Class: ognl.OgnlRuntime
  File: OgnlRuntime.java
  Method: callAppropriateMethod
  Line: 1206 - ognl/OgnlRuntime.java:1206:-1
  at
 
 com.opensymphony.xwork2.util.OgnlUtil.internalSetProperty(OgnlUtil.java:367)
  at com.opensymphony.xwork2.util.OgnlUtil.setProperties(OgnlUtil.java:76)
  .
  .
  .
  Caused by: java.lang.NoSuchMethodException:
  org.apache.struts2.dispatcher.ChartResult.setWidth(java.lang.String)
  at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
  at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
  at
 
 ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
  at
  ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
 
 
  Is there any way to make struts recognize that the value is an int, so it
  needs to call setWidth(int)?
  (*Chris*)

 _
 Hotmail has tools for the New Busy. Search, chat and e-mail from your
 inbox.

 http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_1