You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Xavier Brunel <xa...@profileup.com> on 2001/07/16 20:27:19 UTC

RE: CORRECTION : set-property and form-bean tag in struts-config.xml ??

Ok guys, looking at the Struts starting messages I saw this :

Set org.apache.struts.action.ActionFormBean property numberOfElement to 4

So I understand that Struts try to set the property "numberOfElement" of
ActionFormBean, property which does not exist in ActionFormBean .... so it
does not work....

So I extends ActionFormBean in a class ListActionFormBean adding the
property "numberOfElement"
_________________________________
public class ListeActionFormBean extends ActionFormBean{
private int numberOfElement;

  public void setNumberOfElement(int _numberOfElement){
    numberOfElement=_numberOfElement;
    }

  public int getNumberOfElement(){
    return numberOfElement;
    }
}
_______________________________

Then I modify struts-config.xml with the new reference to ListActionFormBean
for UserListForm:

<form-bean      name="UserListForm"
                    type="com.myapplication.form.UserListForm"

className="com.myapplication.struts.formbean.ListeActionFormBean">
            <set-property property="numberOfElement" value="4"/>
</form-bean>

The rest of my code did not change

When I start Struts I now get the following message :

New com.profileup.struts.formbean.ListActionFormBean
Set com.profileup.struts.formbean.ListActionFormBean properties
Set com.profileup.struts.formbean.ListActionFormBean property
numberOfElement to 4

But I am unable to get back this property to assign it to my UserListForm
!!!!!!
How do you make that possible ???
I presume that it is in the action class associed to the UserListForm
(UserListAction), but which command can I use ??

Thanks for Help

Xavier



-----Message d'origine-----
De : Xavier Brunel [mailto:xavier.brunel@profileup.com]
Envoyé : lundi 16 juillet 2001 20:03
À : 'Struts-User
Objet : set-property and form-bean tag in struts-config.xml ??


Hi all,

I am using Struts since a couple of months and i face a problem with the
<set-property> tab in the <form-bean> tag in struts-config.xml

I understood that the <set-property> could be used to initialize parameters
of JavaBeans (see struts-config.dtd).

But in fact this doesn't work in my case:

I am building an Application System and a Administration System using
Struts,Apache and Tomcat.
I have a "UserListForm" in my Administration System, which is a "ActionForm"
listing all the users registered in my Application System.
This UserListeForm is linked, through action-mapping,with a JSP Page
UserList.jsp, who is just displaying the list.
I would like to give to the Administrators the possibility to fix the
maximum number of element in the list, and giving them the possibility to
view the rest of the list by links "next" and "previous".
This works pretty well if I initialize this number directly in my
application code in UserListeForm.
But when i want to make it fixed through the struts-config.xml, the max
number is never initialized.
Can anybody help me on my problem ???

Here is My Struts-config.xml :
<form-bean   name="UserListForm"
             type="com.myapplication.form.UserListForm"
         <set-property property="numberOfElement" value="4"/>
</form-bean>


Here is my UserListForm extending the ActionForm to be able to use the
<set-property> :

public final class UserListForm extends ActionForm{

  private int numberOfElement;

  public void setNumberOfElement(int _numberOfElement){
    numberOfElement=_numberOfElement;
    }

  public int getNumberOfElement(){
    return numberOfElement;
    }
}




RE:PROBLEM SOLVED : set-property and form-bean tag in struts-config.xml ??

Posted by Xavier Brunel <xa...@profileup.com>.
OK, I found a way to solve my problem (see the problem below)

I make my ListeActionFormBean' methods static and imported this class in my
UserListAction to be able to access to the desired property.
Then I set the similar property to my UserListForm and this is OK !!
It's not clean at all so i am waiting for an other idea .....

Bye

Xavier Brunel

-----Message d'origine-----
De : Xavier Brunel [mailto:xavier.brunel@profileup.com]
Envoyé : lundi 16 juillet 2001 20:27
À : struts-user@jakarta.apache.org
Objet : RE: CORRECTION : set-property and form-bean tag in
struts-config.xml ??


Ok guys, looking at the Struts starting messages I saw this :

Set org.apache.struts.action.ActionFormBean property numberOfElement to 4

So I understand that Struts try to set the property "numberOfElement" of
ActionFormBean, property which does not exist in ActionFormBean .... so it
does not work....

So I extends ActionFormBean in a class ListActionFormBean adding the
property "numberOfElement"
_________________________________
public class ListeActionFormBean extends ActionFormBean{
private int numberOfElement;

  public void setNumberOfElement(int _numberOfElement){
    numberOfElement=_numberOfElement;
    }

  public int getNumberOfElement(){
    return numberOfElement;
    }
}
_______________________________

Then I modify struts-config.xml with the new reference to ListActionFormBean
for UserListForm:

<form-bean      name="UserListForm"
                    type="com.myapplication.form.UserListForm"

className="com.myapplication.struts.formbean.ListeActionFormBean">
            <set-property property="numberOfElement" value="4"/>
</form-bean>

The rest of my code did not change

When I start Struts I now get the following message :

New com.profileup.struts.formbean.ListActionFormBean
Set com.profileup.struts.formbean.ListActionFormBean properties
Set com.profileup.struts.formbean.ListActionFormBean property
numberOfElement to 4

But I am unable to get back this property to assign it to my UserListForm
!!!!!!
How do you make that possible ???
I presume that it is in the action class associed to the UserListForm
(UserListAction), but which command can I use ??

Thanks for Help

Xavier



-----Message d'origine-----
De : Xavier Brunel [mailto:xavier.brunel@profileup.com]
Envoyé : lundi 16 juillet 2001 20:03
À : 'Struts-User
Objet : set-property and form-bean tag in struts-config.xml ??


Hi all,

I am using Struts since a couple of months and i face a problem with the
<set-property> tab in the <form-bean> tag in struts-config.xml

I understood that the <set-property> could be used to initialize parameters
of JavaBeans (see struts-config.dtd).

But in fact this doesn't work in my case:

I am building an Application System and a Administration System using
Struts,Apache and Tomcat.
I have a "UserListForm" in my Administration System, which is a "ActionForm"
listing all the users registered in my Application System.
This UserListeForm is linked, through action-mapping,with a JSP Page
UserList.jsp, who is just displaying the list.
I would like to give to the Administrators the possibility to fix the
maximum number of element in the list, and giving them the possibility to
view the rest of the list by links "next" and "previous".
This works pretty well if I initialize this number directly in my
application code in UserListeForm.
But when i want to make it fixed through the struts-config.xml, the max
number is never initialized.
Can anybody help me on my problem ???

Here is My Struts-config.xml :
<form-bean   name="UserListForm"
             type="com.myapplication.form.UserListForm"
         <set-property property="numberOfElement" value="4"/>
</form-bean>


Here is my UserListForm extending the ActionForm to be able to use the
<set-property> :

public final class UserListForm extends ActionForm{

  private int numberOfElement;

  public void setNumberOfElement(int _numberOfElement){
    numberOfElement=_numberOfElement;
    }

  public int getNumberOfElement(){
    return numberOfElement;
    }
}