If you want less boilerplate code you should consider using Groovy for your
actions.

On Fri, Aug 1, 2008 at 2:55 AM, Lyallex <[EMAIL PROTECTED]> wrote:

> Good Morning
>
> I have an Action called SomeAction
> it has a field called someInt
>
> public class SomeAction extends ActionSupport{
>
>   private int someInt;
>   public int getSomeInt(){return someInt;}
>   public void setSomeInt(int someInt){this.someInt = someInt;}
>
> }
>
> when this action is invoked from a form with value convertable to an
> int, then in the renderer I get hold of someInt like this
> <s:property value="someInt/>
> This only works if there is a getter for someInt
>
> If I go on to edit someInt in a form with this tag in it
> <s:textfield name="someInt"/>
> then the value of the field is set because I provide a setter for someInt
>
> If I do this
>
> public class SomeAction extends ActionSupport{
>
>   public int someInt;
>   //no setter or getter, the attribute is public
>
> }
>
> Then everything works fine
>
> The question is
> If less code good, more code bad then why bother with the setters and
> getters.
>
> This is not a question about the merits of encapsulation and
> information hiding in Object Oriented systems
> It is a question about the reason for not making fields public in a
> Struts2 Action.
>
> TIA
>
> Lyallex
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to