StrutsSpringTestCase - not releasing connections until all tests complete

2009-12-22 Thread carl ballantyne

Hi all,

I am having a problem with my JUnit tests. They are not closing the  
hibernate session until ALL of the tests have finished. Needless to  
say now that I have quite a few tests some are failing because they  
cannot connect to the database.


The app is a Struts 2, Spring 2.5.6 app. I am not using an Open  
Session In View filter preferring to grab all my data before the view  
layer.


I know this is a bit of a general problem and will be difficult for  
people to analyse but maybe someone has run into this before.


I am using the StrutsSpringTestCase which is part of the struts  
release. I notice a few other examples on the web and linked to from  
the docco where people use their own classes.



Cheers,
 Carl.


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



Re: Strusts Error - no Action mapped for action name HelloWorld

2009-12-22 Thread Paweł Wielgus
Hi Dham,
use config browser plugin to verify your configuration:
http://poulwiel.blogspot.com/2009/09/config-browser-plugin-in-struts2.html

Also try to first run blank or demo app from struts_apps.zip and then
modify it to suit your needs.

Best greetings,
Paweł Wielgus.

2009/12/22 dhammikas dhammi...@gmail.com:

 Dear All,
 I am very new to strusts 2.1 and just struggling with up and running the
 hello world app. Following is the error that i am getting

 
 WARNING: Could not find action or result
 There is no Action mapped for action name HelloWorld. - [unknown location]
        at
 com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
        at
 org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
        at
 org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        at
 com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        at
 org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
        at
 org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at
 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at 
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)

 
 Following is the mapping at web.xml


  display-namehw/display-name


  filter
        filter-namestruts2/filter-name

 filter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class
        init-param
                param-nameactionPackages/param-name
                param-valuesample/param-value
        /init-param
    /filter


  filter-mapping
      filter-namestruts2/filter-name
      url-pattern/*/url-pattern
  /filter-mapping


 
 Following is the strusts.xml mapping

 struts
    constant name=struts.enable.DynamicMethodInvocation value=false/
    constant name=struts.devMode value=false/

    package name=sample namespace=/sample extends=struts-default
        action name=HelloWorld class=sample.HelloWorld
            result/pages/helloWorld.jsp/result
        /action
    /package
 /struts


 
 Following is the sample.HelloWorld.java

 package sample;

 import com.opensymphony.xwork2.ActionSupport;

 public class HelloWorld extends ActionSupport{

    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String execute() throws Exception {
        setMessage(Hello World!);
        return SUCCESS;
    }


 }


 
 Following is the /pages/helloWorld.jsp

 %@ taglib prefix=s uri=/struts-tags %

 html
 head
 meta http-equiv=Content-Type content=text/html; charset=UTF-8
 titleHello World/title

 /head
 body
 div align=leftTo your information this is your helloWorld.jsp page under
 WebContent directiory./div
 br
 br
 centerh1s:property value=message//h1/center
 /body
 /html


 
 Following is the url being used to access the helloWorld.jsp

 http://localhost:8080/hw/sample/HelloWorld.action
 http://localhost:8080/hw/sample/HelloWorld.action



 

 ANYBODY, PLEASE BE KIND ENOUGH TO HELP ME TO GET RID OF THIS TERRIBLE DAMN
 ERROR.

 Thanking and please let me know any concerns/thoughts.
 Dham

 --
 View 

Re: Strusts Error - no Action mapped for action name HelloWorld

2009-12-22 Thread dhammikas

Dear Paweł, 

Thanks a lot for the kind reply, i got in with the browser plugin feature
and it shows nothing with the Actions in default namespace , so i guess
there should be some basic mismatch in my app though it seems ok and nice.. 
btw i found a better post about browser plugin here, 
http://devtalks.blogspot.com/2009/10/struts2-config-browser-plugin.html
http://devtalks.blogspot.com/2009/10/struts2-config-browser-plugin.html 


Well, now i am on with ur second suggestion, modifying the blank demo and
try to make up and running.. let me come back with any good news.. 
Thanks a lot for advice. 
Dham





Paweł Wielgus wrote:
 
 Hi Dham,
 use config browser plugin to verify your configuration:
 http://poulwiel.blogspot.com/2009/09/config-browser-plugin-in-struts2.html
 
 Also try to first run blank or demo app from struts_apps.zip and then
 modify it to suit your needs.
 
 Best greetings,
 Paweł Wielgus.
 
 2009/12/22 dhammikas dhammi...@gmail.com:

 Dear All,
 I am very new to strusts 2.1 and just struggling with up and running the
 hello world app. Following is the error that i am getting

 
 WARNING: Could not find action or result
 There is no Action mapped for action name HelloWorld. - [unknown
 location]
        at
 com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
        at
 org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
        at
 org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        at
 com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        at
 org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
        at
 org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at
 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)

 
 Following is the mapping at web.xml


  display-namehw/display-name


  filter
        filter-namestruts2/filter-name

 filter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class
        init-param
                param-nameactionPackages/param-name
                param-valuesample/param-value
        /init-param
    /filter


  filter-mapping
      filter-namestruts2/filter-name
      url-pattern/*/url-pattern
  /filter-mapping


 
 Following is the strusts.xml mapping

 struts
    constant name=struts.enable.DynamicMethodInvocation value=false/
    constant name=struts.devMode value=false/

    package name=sample namespace=/sample extends=struts-default
        action name=HelloWorld class=sample.HelloWorld
            result/pages/helloWorld.jsp/result
        /action
    /package
 /struts


 
 Following is the sample.HelloWorld.java

 package sample;

 import com.opensymphony.xwork2.ActionSupport;

 public class HelloWorld extends ActionSupport{

    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String execute() throws Exception {
        setMessage(Hello World!);
        return SUCCESS;
    }


 }


 
 Following is the /pages/helloWorld.jsp

 %@ taglib prefix=s uri=/struts-tags %

 html
 head
 meta http-equiv=Content-Type content=text/html; charset=UTF-8
 titleHello World/title

 /head
 body
 div align=leftTo 

Re: Strusts Error - no Action mapped for action name HelloWorld

2009-12-22 Thread dhammikas

Please return later to see if your message was accepted by the mailing list.
If there is a problem, Nabble will alert you by email and provide additional
instructions.
Dear Paweł,

Thanks a lot for the kind reply, i got in with the browser plugin feature
and it shows nothing with the Actions in default namespace , so i guess
there should be some basic mismatch in my app though it seems ok and nice..
btw i found a better post about browser plugin here,
http://devtalks.blogspot.com/2009/10/struts2-config-browser-plugin.html
http://devtalks.blogspot.com/2009/10/struts2-config-browser-plugin.html 


Well, now i am on with ur second suggestion, modifying the blank demo and
try to make up and running.. let me come back with any good news..
Thanks a lot for advice.
Dham





Paweł Wielgus wrote:
 
 Hi Dham,
 use config browser plugin to verify your configuration:
 http://poulwiel.blogspot.com/2009/09/config-browser-plugin-in-struts2.html
 
 Also try to first run blank or demo app from struts_apps.zip and then
 modify it to suit your needs.
 
 Best greetings,
 Paweł Wielgus.
 
 2009/12/22 dhammikas dhammi...@gmail.com:

 Dear All,
 I am very new to strusts 2.1 and just struggling with up and running the
 hello world app. Following is the error that i am getting

 
 WARNING: Could not find action or result
 There is no Action mapped for action name HelloWorld. - [unknown
 location]
        at
 com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
        at
 org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
        at
 org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        at
 com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        at
 org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
        at
 org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at
 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)

 
 Following is the mapping at web.xml


  display-namehw/display-name


  filter
        filter-namestruts2/filter-name

 filter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class
        init-param
                param-nameactionPackages/param-name
                param-valuesample/param-value
        /init-param
    /filter


  filter-mapping
      filter-namestruts2/filter-name
      url-pattern/*/url-pattern
  /filter-mapping


 
 Following is the strusts.xml mapping

 struts
    constant name=struts.enable.DynamicMethodInvocation value=false/
    constant name=struts.devMode value=false/

    package name=sample namespace=/sample extends=struts-default
        action name=HelloWorld class=sample.HelloWorld
            result/pages/helloWorld.jsp/result
        /action
    /package
 /struts


 
 Following is the sample.HelloWorld.java

 package sample;

 import com.opensymphony.xwork2.ActionSupport;

 public class HelloWorld extends ActionSupport{

    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String execute() throws Exception {
        setMessage(Hello World!);
        return SUCCESS;
    }


 }


 
 Following is the /pages/helloWorld.jsp

 %@ taglib 

Re: Strusts Error - no Action mapped for action name HelloWorld

2009-12-22 Thread dhammikas

Hello All, 

I was able to bring the strusts's blank demo up and running :) , but my
previous app is also holding the same piece of architecture, i went thourhg
and checked twice, the structure/features and syntax are totally identical
and am not able to find out where the actual fault is.. 

Anyway I have done what I need in a alternative way... Thanks a lot Pawel
for the tips..

Cheers 


Dear Paweł,

Thanks a lot for the kind reply, i got in with the browser plugin feature
and it shows nothing with the Actions in default namespace , so i guess
there should be some basic mismatch in my app though it seems ok and nice..
btw i found a better post about browser plugin here,
http://devtalks.blogspot.com/2009/10/struts2-config-browser-plugin.html
http://devtalks.blogspot.com/2009/10/struts2-config-browser-plugin.html 


Well, now i am on with ur second suggestion, modifying the blank demo and
try to make up and running.. let me come back with any good news..
Thanks a lot for advice.
Dham





Paweł Wielgus wrote:
 
 Hi Dham,
 use config browser plugin to verify your configuration:
 http://poulwiel.blogspot.com/2009/09/config-browser-plugin-in-struts2.html
 
 Also try to first run blank or demo app from struts_apps.zip and then
 modify it to suit your needs.
 
 Best greetings,
 Paweł Wielgus.
 
 2009/12/22 dhammikas dhammi...@gmail.com:

 Dear All,
 I am very new to strusts 2.1 and just struggling with up and running the
 hello world app. Following is the error that i am getting

 
 WARNING: Could not find action or result
 There is no Action mapped for action name HelloWorld. - [unknown
 location]
        at
 com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:178)
        at
 org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61)
        at
 org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
        at
 com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47)
        at
 org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478)
        at
 org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
        at
 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
        at
 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at
 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at
 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at
 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at
 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at
 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at
 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at
 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at
 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at
 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at
 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Unknown Source)

 
 Following is the mapping at web.xml


  display-namehw/display-name


  filter
        filter-namestruts2/filter-name

 filter-classorg.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter/filter-class
        init-param
                param-nameactionPackages/param-name
                param-valuesample/param-value
        /init-param
    /filter


  filter-mapping
      filter-namestruts2/filter-name
      url-pattern/*/url-pattern
  /filter-mapping


 
 Following is the strusts.xml mapping

 struts
    constant name=struts.enable.DynamicMethodInvocation value=false/
    constant name=struts.devMode value=false/

    package name=sample namespace=/sample extends=struts-default
        action name=HelloWorld class=sample.HelloWorld
            result/pages/helloWorld.jsp/result
        /action
    /package
 /struts


 
 Following is the sample.HelloWorld.java

 package sample;

 import com.opensymphony.xwork2.ActionSupport;

 public class HelloWorld extends ActionSupport{

    private String message;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String execute() 

if tag with #parameters

2009-12-22 Thread foo bar
Hi all,

I'm testing for the existence of a request parameter in a jsp page in Struts 2

%@ taglib prefix=s uri=/struts-tags%
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
http://www.w3.org/TR/html4/strict.dtd;
s:property value=#parameters.messageKey/br/
s:if test=%{#parameters.messageKey == 'yes'}
yes
/s:if
s:else
no
/s:else

But, whatever I do, result is always no

Tested with these cases:

test.jsp
test.jsp?messageKey=
test.jsp?messageKey=yes
test.jsp?messageKey=no

Changed it to s:if test=#parameters.messageKey == 'yes', same results
Changed it to s:if test={#parameters.messageKey == 'yes'}, results
are negated as above, ie you got no when previously you got yes

What's the solution here ?

Cheers

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



Re: if tag with #parameters

2009-12-22 Thread Saeed Iqbal
If it is a request parameter, then make a setter for it to get set and
getter to retrieve it and use % instead of #

If you want to have the parameter in the page context use the s:set with id



On Tue, Dec 22, 2009 at 3:36 PM, foo bar linut...@gmail.com wrote:

 Hi all,

 I'm testing for the existence of a request parameter in a jsp page in
 Struts 2

 %@ taglib prefix=s uri=/struts-tags%
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
 http://www.w3.org/TR/html4/strict.dtd;
 s:property value=#parameters.messageKey/br/
 s:if test=%{#parameters.messageKey == 'yes'}
 yes
 /s:if
 s:else
 no
 /s:else

 But, whatever I do, result is always no

 Tested with these cases:

 test.jsp
 test.jsp?messageKey=
 test.jsp?messageKey=yes
 test.jsp?messageKey=no

 Changed it to s:if test=#parameters.messageKey == 'yes', same results
 Changed it to s:if test={#parameters.messageKey == 'yes'}, results
 are negated as above, ie you got no when previously you got yes

 What's the solution here ?

 Cheers

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




-- 
Saeed Iqbal
Independant Consultant
J2EE - Application Architect / Developer


Re: if tag with #parameters

2009-12-22 Thread foo bar
Hi,

I would prefer not to use getter/setter.
What I really want to know is, why is this not working as expected ?

Anyway, I solved it

s:if test=#parameters.messageKey[0] == 'yes'

#parameters.messageKey is of type String[], which make sense now


On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal saee...@gmail.com wrote:
 If it is a request parameter, then make a setter for it to get set and
 getter to retrieve it and use % instead of #

 If you want to have the parameter in the page context use the s:set with id



 On Tue, Dec 22, 2009 at 3:36 PM, foo bar linut...@gmail.com wrote:

 Hi all,

 I'm testing for the existence of a request parameter in a jsp page in
 Struts 2

 %@ taglib prefix=s uri=/struts-tags%
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
 http://www.w3.org/TR/html4/strict.dtd;
 s:property value=#parameters.messageKey/br/
 s:if test=%{#parameters.messageKey == 'yes'}
 yes
 /s:if
 s:else
 no
 /s:else

 But, whatever I do, result is always no

 Tested with these cases:

 test.jsp
 test.jsp?messageKey=
 test.jsp?messageKey=yes
 test.jsp?messageKey=no

 Changed it to s:if test=#parameters.messageKey == 'yes', same results
 Changed it to s:if test={#parameters.messageKey == 'yes'}, results
 are negated as above, ie you got no when previously you got yes

 What's the solution here ?

 Cheers

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




 --
 Saeed Iqbal
 Independant Consultant
 J2EE - Application Architect / Developer


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



Re: if tag with #parameters

2009-12-22 Thread Gabriel Belingueres
Yes, parameters are String arrays. As a side note, see the following
post because sometimes OGNL evaluates things differently:

http://www.mail-archive.com/user@struts.apache.org/msg80015.html

2009/12/22 foo bar linut...@gmail.com:
 Hi,

 I would prefer not to use getter/setter.
 What I really want to know is, why is this not working as expected ?

 Anyway, I solved it

 s:if test=#parameters.messageKey[0] == 'yes'

 #parameters.messageKey is of type String[], which make sense now


 On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal saee...@gmail.com wrote:
 If it is a request parameter, then make a setter for it to get set and
 getter to retrieve it and use % instead of #

 If you want to have the parameter in the page context use the s:set with id



 On Tue, Dec 22, 2009 at 3:36 PM, foo bar linut...@gmail.com wrote:

 Hi all,

 I'm testing for the existence of a request parameter in a jsp page in
 Struts 2

 %@ taglib prefix=s uri=/struts-tags%
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
 http://www.w3.org/TR/html4/strict.dtd;
 s:property value=#parameters.messageKey/br/
 s:if test=%{#parameters.messageKey == 'yes'}
 yes
 /s:if
 s:else
 no
 /s:else

 But, whatever I do, result is always no

 Tested with these cases:

 test.jsp
 test.jsp?messageKey=
 test.jsp?messageKey=yes
 test.jsp?messageKey=no

 Changed it to s:if test=#parameters.messageKey == 'yes', same results
 Changed it to s:if test={#parameters.messageKey == 'yes'}, results
 are negated as above, ie you got no when previously you got yes

 What's the solution here ?

 Cheers

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




 --
 Saeed Iqbal
 Independant Consultant
 J2EE - Application Architect / Developer


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



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



best practices in struts 2.1 - Tiles and Convention - clean URLs with minimum number of actions

2009-12-22 Thread Charles Parker
I'm using struts 2.1.8.1 here and have a question about best practices 
in the following situation:


I have a form page, 'register'. It takes several fields, username, 
password, etc.


I want the initial form page to be rendered via GET:

http://my.server.net/register

This shows the blank form (the tile definition below), without 
attempting to validate the fields.


  definition name=registrationPage extends=defaultLayout
  put-attribute name=content 
value=/WEB-INF/pages/registration.jsp/

  /definition

On POST to the same URL 'http://my.server.net/register', I want to 
perform validation on the form, (via register-validation.xml or 
Annotation). If the form validates then perform the action that triggers 
the underlying business logic. Otherwise re-display the form with 
validation errors (again, same URL, 'http://my.server.net/register').


I am using the Convention plugin and the Tiles plugin. The combination 
of these two seems to throw a wrench in the works.
It seems that with the Convention plugin, I can only depend on execute() 
being called, or I need to define multiple actions.


The approach I'm using now works reasonably well but there must be a 
cleaner way:


@ParentPackage(testing)
public class Register extends ActionSupport
{
@Action(value=register,result...@result(name=input, 
type=tiles, location=registrationPage)})

@SkipValidation
public String execute() throws Exception
{
return this.isBlank() ? INPUT : submit;
}

@Action
(
value=register-submit,
results=
{
@Result(name=input, type=tiles, 
location=registrationPage),
@Result(name=error, type=tiles, 
location=registrationPage),
@Result(name=success, type=tiles, 
location=registrationSuccessfulPage)

}
)
public String executeValidate() throws Exception
{
// perform business logic
return SUCCESS;
}

private boolean isBlank()
{
return StringUtils.isBlank(this.username)  
StringUtils.isBlank(this.password)

}
}

Someone can still link in to /register-submit, which isn't awful, since 
validation is performed. But I'd like to minimize the number of 
actionable URLs on my site and avoid writing an isBlank() method for 
each form.


It would seem more straightforward if I could depend on an INPUT result 
on the first load of the page (with @SkipValidation), and then execute() 
thereafter, with only a single action defined at the class level instead 
of multiple actions at the method level.



Is this possible, and if so, what is the most appropriate way to do this 
via struts 2.1?


I am addicted to the Convention plugin annotation, and I cannot do 
without Tiles.


For reference, I'm using the following in struts.xml:

constant name=struts.convention.action.alwaysMapExecute value=false/

package name=testing extends=struts-default
!-- Set the tiles result type as the default for this package. --
result-types
result-type name=tiles 
class=org.apache.struts2.views.tiles.TilesResult default=true/

/result-types
/package

Many thanks for any alternatives or refinements of this approach.

/ chuck


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



[S2] s:select can't use ENUM type

2009-12-22 Thread mailtolouis2020-struts
Hi,

I got problem to using ENUM type in s:select, here is my code:

s:select label=Sex
   name=user.sex
   list=getComboBox(ComboBoxType.SEX)
   listKey=key
   listValue=value
   value=user.sex/

but if I change to use String (e.g: list=getComboBox('SEX')),
and do the conversion in the action then it working fine.

Is it a bug?

Regards
LV

Re: if tag with #parameters

2009-12-22 Thread xerax nono
I think that the correct test is:

s:property value=#messageKey/br/
s:if test=%{#messageKey == 'yes'}
yes
2009/12/22 foo bar linut...@gmail.com

 Hi all,

 I'm testing for the existence of a request parameter in a jsp page in
 Struts 2

 %@ taglib prefix=s uri=/struts-tags%
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN
 http://www.w3.org/TR/html4/strict.dtd;
 s:property value=#parameters.messageKey/br/
 s:if test=%{#parameters.messageKey == 'yes'}
 yes
 /s:if
 s:else
 no
 /s:else

 But, whatever I do, result is always no

 Tested with these cases:

 test.jsp
 test.jsp?messageKey=
 test.jsp?messageKey=yes
 test.jsp?messageKey=no

 Changed it to s:if test=#parameters.messageKey == 'yes', same results
 Changed it to s:if test={#parameters.messageKey == 'yes'}, results
 are negated as above, ie you got no when previously you got yes

 What's the solution here ?

 Cheers

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




-- 
Serafin Hernandez Blazquez
649 81 64 87


Re: [S2] s:select can't use ENUM type

2009-12-22 Thread Steven Yang
what does getComboBox accepting? an Enum value or Enum array?
if an Enum value then you have to do @{include full package
path}comboboxt...@sex

On Wed, Dec 23, 2009 at 12:15 AM, mailtolouis2020-str...@yahoo.com wrote:

 Hi,

 I got problem to using ENUM type in s:select, here is my code:

 s:select label=Sex
   name=user.sex
   list=getComboBox(ComboBoxType.SEX)
   listKey=key
   listValue=value
   value=user.sex/

 but if I change to use String (e.g: list=getComboBox('SEX')),
 and do the conversion in the action then it working fine.

 Is it a bug?

 Regards
 LV


how do I use absolute url actions in html:form tag with struts 1.3.8

2009-12-22 Thread Jason Novotny

Hi,

I'm a Struts newbie and am tasked with trying to change relative 
URLs on our site to be absolute. I have a form that looks like:


html:form action=/fcon/MyAction

and once it renders it displays:

form id=myForm method=GET 
action=/modules/mymodule/fcon/MyAction.do onsubmit=return 
validateFilterForm(event, this);


What I'd like is to have it render an absolute URL:

form id=myForm method=GET 
action=http://www.mysite.com/modules/mymodule/fcon/MyAction.do; 
onsubmit=return validateFilterForm(event, this);


How can I do this?

Thanks a lot, Jason

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