You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Barrows <jb...@sssc.com> on 2004/09/03 19:02:06 UTC

ARRRGGGGHHHH!!! I'm being stupid again....

I'm trying to use the set-property tag in the struts-config file.  I know I'm being stupid, but what exactly is it?
It's not finding the property to set.

Okay if I have in my struts-config.xml:
<action name="loanForm" path="/loanAppWizard" 	type="com.sssc.shtuff.actions.LoanAppWizardAction" scope="session">

	<set-property property="maxNumberOfPages" value="2" />

	<forward name="page1" path="/demographics.jsp"></forward>
	<forward name="page2" path="/references.jsp"></forward>
	<forward name="done" path="/done.jsp"></forward>
</action>

and this in my action class:
public class LoanAppWizardAction extends Action {

	blah

    /**Read only property from inside this action that indicates what number is
     * the last page.
     */
    private int maxNumberOfPages = 0;

Lots o' blah
                    
    /**
     * @return
     */
    public int getMaxNumberOfPages() {
        return maxNumberOfPages;
    }    
    
    public void setMaxNumberOfPages(int i) {
        maxNumberOfPages = i;
    }
}
Then I should end up with maxNumberOfPages set to 2, and not:
The following exception was logged java.lang.NoSuchMethodException: Bean has no property named maxNumberOfPages

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


Re: ARRRGGGGHHHH!!! I'm being stupid again....

Posted by Bill Siggelkow <bi...@bellsouth.net>.
The <set-property> in nested <action> applies to the ActionMapping 
object not the Action.

Jim Barrows wrote:
> I'm trying to use the set-property tag in the struts-config file.  I know I'm being stupid, but what exactly is it?
> It's not finding the property to set.
> 
> Okay if I have in my struts-config.xml:
> <action name="loanForm" path="/loanAppWizard" 	type="com.sssc.shtuff.actions.LoanAppWizardAction" scope="session">
> 
> 	<set-property property="maxNumberOfPages" value="2" />
> 
> 	<forward name="page1" path="/demographics.jsp"></forward>
> 	<forward name="page2" path="/references.jsp"></forward>
> 	<forward name="done" path="/done.jsp"></forward>
> </action>
> 
> and this in my action class:
> public class LoanAppWizardAction extends Action {
> 
> 	blah
> 
>     /**Read only property from inside this action that indicates what number is
>      * the last page.
>      */
>     private int maxNumberOfPages = 0;
> 
> Lots o' blah
>                     
>     /**
>      * @return
>      */
>     public int getMaxNumberOfPages() {
>         return maxNumberOfPages;
>     }    
>     
>     public void setMaxNumberOfPages(int i) {
>         maxNumberOfPages = i;
>     }
> }
> Then I should end up with maxNumberOfPages set to 2, and not:
> The following exception was logged java.lang.NoSuchMethodException: Bean has no property named maxNumberOfPages


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


Re: ARRRGGGGHHHH!!! I'm being stupid again....

Posted by Martin Gainty <mg...@hotmail.com>.
To quote Fawcette-
"It doesn't take much to be a bean. A class just needs a public constructor
that takes no arguments and get and set methods for each significant
property such that a property named foo will have getFoo() and setFoo()
methods. Technically, it must just support introspection, but that is
usually achieved by using the get and set naming convention. Here is a
simple Stuff bean for our experiments that has a String and an integer for
properties
public class Stuff {
   private int k = 1;
   private String s = "hello";

   public Stuff() {}
   public int getK() {return k;}
   public String getS(){return s;}
   public void setK(int i) {k=i;}
   public void setS(String t){s=t;}
};"

/*I noticed that I did not see your properties break out to a separate Bean
Classwith a public constructor as well as get/set for each property*/

HTH,
Martin
----- Original Message -----
From: "Jim Barrows" <jb...@sssc.com>
To: "Struts User List (E-mail)" <us...@struts.apache.org>
Sent: Friday, September 03, 2004 1:02 PM
Subject: ARRRGGGGHHHH!!! I'm being stupid again....


I'm trying to use the set-property tag in the struts-config file.  I know
I'm being stupid, but what exactly is it?
It's not finding the property to set.

Okay if I have in my struts-config.xml:
<action name="loanForm" path="/loanAppWizard"
type="com.sssc.shtuff.actions.LoanAppWizardAction" scope="session">

<set-property property="maxNumberOfPages" value="2" />

<forward name="page1" path="/demographics.jsp"></forward>
<forward name="page2" path="/references.jsp"></forward>
<forward name="done" path="/done.jsp"></forward>
</action>

and this in my action class:
public class LoanAppWizardAction extends Action {

blah

    /**Read only property from inside this action that indicates what number
is
     * the last page.
     */
    private int maxNumberOfPages = 0;

Lots o' blah

    /**
     * @return
     */
    public int getMaxNumberOfPages() {
        return maxNumberOfPages;
    }

    public void setMaxNumberOfPages(int i) {
        maxNumberOfPages = i;
    }
}
Then I should end up with maxNumberOfPages set to 2, and not:
The following exception was logged java.lang.NoSuchMethodException: Bean has
no property named maxNumberOfPages

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


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