You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Ritvars Rundzāns <rr...@gmail.com> on 2009/07/13 16:21:11 UTC

Getter in action triggers twice. Bug?

Hi!

I am wondering is this Struts2 ( *2.1.6* ) fw bug, or am i just
misunderstanding something :). I created action mapping witch maps to an
action and passes two args to it from base url (not param part), like this:

        <action name="person-*-*" class="example.Person">
            <param name="cmd">{1}</param>
            <param name="id">{2}</param>

            <result>/example/abc.jsp</result>
        </action>

Then i created action, which justs do nothing :), but print something when
setter are called:

    public void setCmd(String cmd) {
        System.out.println( "set:cmd" );
        this.cmd = cmd;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        System.out.println( "set:id" );
        this.id = id;
    }
    public String getDum() {
        return dum;
    }
    public void setDum(String dum) {
        System.out.println( "set:dum" );
        this.dum = dum;
    }

Requesting URL
http://localhost:8080/struts_2_test/example/person-view-2?dum=3 gives:
set:cmd
set:id
set:cmd
set:dum
set:id

I know that setter is just setter, but this thing really annoys me :). Any
thoughts? Thanks!

Re: Getter in action triggers twice. Bug?

Posted by Dave Newton <ne...@yahoo.com>.
Please ask this question on the struts-user mailing list. The struts-dev 
list is for the development of Struts itself.

http://struts.apache.org/mail.html

Thanks,
Dave

Ritvars Rundza-ns wrote:
> Hi!
> 
> I am wondering is this Struts2 ( *2.1.6* ) fw bug, or am i just 
> misunderstanding something :). I created action mapping witch maps to an 
> action and passes two args to it from base url (not param part), like this:
> 
>         <action name="person-*-*" class="example.Person">
>             <param name="cmd">{1}</param>
>             <param name="id">{2}</param>
>            
>             <result>/example/abc.jsp</result>
>         </action>
> 
> Then i created action, which justs do nothing :), but print something 
> when setter are called:
> 
>     public void setCmd(String cmd) {
>         System.out.println( "set:cmd" );
>         this.cmd = cmd;
>     }
>     public String getId() {
>         return id;
>     }
>     public void setId(String id) {
>         System.out.println( "set:id" );
>         this.id <http://this.id> = id;
>     }
>     public String getDum() {
>         return dum;
>     }
>     public void setDum(String dum) {
>         System.out.println( "set:dum" );
>         this.dum = dum;
>     }
> 
> Requesting URL 
> http://localhost:8080/struts_2_test/example/person-view-2?dum=3 gives:
> set:cmd
> set:id
> set:cmd
> set:dum
> set:id
> 
> I know that setter is just setter, but this thing really annoys me :). 
> Any thoughts? Thanks!
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org

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


Re: Getter in action triggers twice. Bug?

Posted by Ritvars Rundzāns <rr...@gmail.com>.
I understand and agree your way of thinking. Its true i tried struts 2 the
first time today.

But. This misconfiguration thing is doubtly possible, i think, because i
used struts2 blank app as a base of my "test". Just 1 filter @ web.xml
(struts filter), @ struts xml - 2 constansts were set:
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />

+action mapping for test (pasted in my first post).

Ok, thanks anyway, will go and try out user list.

Re: Getter in action triggers twice. Bug?

Posted by Musachy Barroso <mu...@gmail.com>.
I agree with you in principle, but there is a good chance that it is
something not properly configured, like the static params interceptor
applied twice to the action vs a struts bug.

musachy

On Mon, Jul 13, 2009 at 9:54 AM, Ritvars Rundzāns<rr...@gmail.com> wrote:
> If you think this post is inappropriate @ this mailing list, i disagree with
> you. Despite of fact this (twice-triggering) is simple thing/fact, it is
> more related to struts2 action handling implementation (dev thing) then my
> lack of knowledge (user list).
>
> Anyway, i will give it a try. Others are still welcome to discuss here ;).
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Getter in action triggers twice. Bug?

Posted by Ritvars Rundzāns <rr...@gmail.com>.
If you think this post is inappropriate @ this mailing list, i disagree with
you. Despite of fact this (twice-triggering) is simple thing/fact, it is
more related to struts2 action handling implementation (dev thing) then my
lack of knowledge (user list).

Anyway, i will give it a try. Others are still welcome to discuss here ;).

Re: Getter in action triggers twice. Bug?

Posted by Musachy Barroso <mu...@gmail.com>.
please post this question on the user mailing list.

thanks
musachy

On Mon, Jul 13, 2009 at 7:21 AM, Ritvars Rundzāns<rr...@gmail.com> wrote:
> Hi!
>
> I am wondering is this Struts2 ( 2.1.6 ) fw bug, or am i just
> misunderstanding something :). I created action mapping witch maps to an
> action and passes two args to it from base url (not param part), like this:
>
>         <action name="person-*-*" class="example.Person">
>             <param name="cmd">{1}</param>
>             <param name="id">{2}</param>
>
>             <result>/example/abc.jsp</result>
>         </action>
>
> Then i created action, which justs do nothing :), but print something when
> setter are called:
>
>     public void setCmd(String cmd) {
>         System.out.println( "set:cmd" );
>         this.cmd = cmd;
>     }
>     public String getId() {
>         return id;
>     }
>     public void setId(String id) {
>         System.out.println( "set:id" );
>         this.id = id;
>     }
>     public String getDum() {
>         return dum;
>     }
>     public void setDum(String dum) {
>         System.out.println( "set:dum" );
>         this.dum = dum;
>     }
>
> Requesting URL
> http://localhost:8080/struts_2_test/example/person-view-2?dum=3 gives:
> set:cmd
> set:id
> set:cmd
> set:dum
> set:id
>
> I know that setter is just setter, but this thing really annoys me :). Any
> thoughts? Thanks!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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