Author Login
Post Reply
user Digest 3 Feb 2008 00:16:00 -0000 Issue 7840
Topics (messages 182137 through 182156):
Re: Struts and Windows Authentication
182137 by: Arun
182140 by: Martin Gainty
Re: actions defined in a package are visible in other packages??
182138 by: Dave Newton
182152 by: paulbrickell
[OT] Re: Struts and Windows Authentication
182139 by: Dave Newton
reset problem for a dynavalidator form
182141 by: Ashima Beri
182145 by: Laurie Harper
182147 by: Ashima Beri
182148 by: Dave Newton
182149 by: Laurie Harper
182150 by: Ashima Beri
182151 by: Ashima Beri
session delete event
182142 by: Sergey Livanov
182146 by: Laurie Harper
Re: How to create a new Struts2 project with maven2?
182143 by: Laurie Harper
Re: Struts, Interceptor error message customization
182144 by: Laurie Harper
Re: DataGrid, Struts layout and Struts 2
182153 by: nandha
Re: AjaxTag 1.3 support?
182154 by: Griffith, Michael *
182155 by: Dave Newton
182156 by: Jeromy Evans
Administrivia:
---------------------------------------------------------------------
To post to the list, e-mail: user@(protected)
To unsubscribe, e-mail: user-digest-unsubscribe@(protected)
For additional commands, e-mail: user-digest-help@(protected)
----------------------------------------------------------------------

Attachment:
user_182137.ezm (zipped)I am using tomcat. Is it possible implement container managed security with
this?
On Feb 1, 2008 7:42 PM, Cory D. Wiles <kwylez@(protected):
> At my job we authenticate our users directly using Active Directory using
> container managed security.
>
> What container are you using?
>
> On Feb 1, 2008 4:48 AM, Antonio Petrelli <antonio.petrelli@(protected)>
> wrote:
>
> > 2008/2/1, Arun <arun.george.1981@(protected)>:
> > > Hi,
> > >
> > > I have a web application in which I need to implement windows
> > > authentication.
> > > Basically there is a login screen where we can enter username and
> > password.
> > > These users are the users that are there in OS.
> > > The username is like domainname\username and password is the password.
> > > A basic authentication dialog wil popup asking this. It should
> > authenticate
> > > against the domain name server.
> > > And forward to home page with the login information.
> > > Can anybody help me on this.?
> >
> > This may help you a lot:
> > http://jcifs.samba.org/src/docs/ntlmhttpauth.html
> >
> > Ciao
> > Antonio
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
> >
>
>
> --
> Cory Wiles
> kwylez@(protected)
> http://www.corywiles.com
> http://alphaprevails.blogspot.com
>
--
Thanks
Arun George

Attachment:
user_182140.ezm (zipped)Hi Arun-
following up on Antonio's suggestion-
did you look at setting the AD properties ?
http://jcifs.samba.org/src/docs/ntlmhttpauth.html#props
(and then restart the container)
?
Martin
----- Original Message -----
From: "Arun" <arun.george.1981@(protected)>
To: "Struts Users Mailing List" <user@(protected)>
Sent: Saturday, February 02, 2008 10:48 AM
Subject: Re: Struts and Windows Authentication
> I am using tomcat. Is it possible implement container managed security
with
> this?
>
> On Feb 1, 2008 7:42 PM, Cory D. Wiles <kwylez@(protected):
>
> > At my job we authenticate our users directly using Active Directory
using
> > container managed security.
> >
> > What container are you using?
> >
> > On Feb 1, 2008 4:48 AM, Antonio Petrelli <antonio.petrelli@(protected)>
> > wrote:
> >
> > > 2008/2/1, Arun <arun.george.1981@(protected)>:
> > > > Hi,
> > > >
> > > > I have a web application in which I need to implement windows
> > > > authentication.
> > > > Basically there is a login screen where we can enter username and
> > > password.
> > > > These users are the users that are there in OS.
> > > > The username is like domainname\username and password is the
password.
> > > > A basic authentication dialog wil popup asking this. It should
> > > authenticate
> > > > against the domain name server.
> > > > And forward to home page with the login information.
> > > > Can anybody help me on this.?
> > >
> > > This may help you a lot:
> > > http://jcifs.samba.org/src/docs/ntlmhttpauth.html
> > >
> > > Ciao
> > > Antonio
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > > For additional commands, e-mail: user-help@(protected)
> > >
> > >
> >
> >
> > --
> > Cory Wiles
> > kwylez@(protected)
> > http://www.corywiles.com
> > http://alphaprevails.blogspot.com
> >
>
>
>
> --
> Thanks
> Arun George
>

Attachment:
user_182138.ezm (zipped)I can only dupe this if I leave out the leading "/" (slash) in my namespace
attribute of my package.
Off the top of my head I'd say that the dispatcher is looking in a "/"
namespace (as opposed to the "" (empty string) namespace) and can't find the
action there (or is looking in "" instead of "/", maybe).
If you use the leading "/" in your namespace attribute (both in your S2
config file and in the tags) it should work. (Although I just tried it only
in config and not in the tag and that worked too, but I wouldn't recommend
it.)
Dave
--- paulbrickell <paul.brickell@(protected):
>
> Dave,
>
> OK did as you suggested, cranked up the logging level and I do now get some
> logging. I created a little sandbox app to test out some things with and
> simplifying has really helped. Heres what I have now
>
> <div>
> <s:action name="test" namespace="secondary" executeResult="true"/>
> </div>
> <div>
> <s:action name="secondary/test.action" executeResult="true"/>
> </div>
> <div>
> <s:url id="testUrlId" namespace="secondary" action="test"/>
> <s:a href="%{testUrlId}">execute test action</s:a>
> </div>
>
>
> Now the first div works exactly as expected.
>
> The second one also works how would expect it to. It Always generates a
> stack trace with the error message "There is no Action mapped for action
> name secondary/test.ation" regardless of how I try to specify the 'path' to
> the action. Now I know that the namespace does not represent a path and
> that
> I need to use the namespace attribute. I think thats fine and that doesn't
> give me any kind of problem. I can always specify the namespace attribute
> and all is well.
>
> But the third div is my problem. There seems to be no way a can form a URL
> for s:a tag that lets me build a link to the namespaced action. The link
> directs the browser to...
>
> http://localhost:8080/sandbox/secondary/test.action
>
> That seems ok to me. but when I click this link I get this...
>
> [example] DEBUG [http-8080-1] DefaultActionProxy.<init>(65) | Creating an
> DefaultActionProxy for namespace and action name test
> [example] ERROR [http-8080-1] Dispatcher.serviceAction(512) | Could not
> find
> action or result
> There is no Action mapped for action name test. - [unknown location]
> at
>
com.opensymphony.xwork2.DefaultActionProxy.prepare (
DefaultActionProxy.java:186)
> at
>
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy (
StrutsActionProxyFactory.java:41)
> at
>
org.apache.struts2.dispatcher.Dispatcher.serviceAction (
Dispatcher.java:494)
> at
>
org.apache.struts2.dispatcher.FilterDispatcher.doFilter (
FilterDispatcher.java:419)
> 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:175)
> 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:263)
> at
>
org.apache.coyote.http11.Http11Processor.process (
Http11Processor.java:844)
> at
>
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
> at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> at
java.lang.Thread.run(Unknown Source)
>
>
> (Hope its OK to dump stacktraces here, apologies if its bad form).
>
> it seems from the debug line "[example] DEBUG [http-8080-1]
> DefaultActionProxy.<init>(65) | Creating an DefaultActionProxy for
> namespace
> and action name test" That there is no namespace defined. I will try to
> step
> throught the DefaultActionProxy next to find out why that might be.
>
> If thats correct (the link represents a path after all), am I going to have
> to have all my links in the root namespace? I can do this of course, but it
> seems a ilttle restrictive.
>
> Just have to say thanks for all the feedback. I am always impressed with
> the
> help given on these lists.
>
> Paul B.
>
>
>
> newton.dave wrote:
> >
> > --- paulbrickell <paul.brickell@(protected):
> >> I don't think I was clear about what I am seeing. If I have an action
> tag
> >> in my page like this...
> >>
> >> <div>
> >> <s:action name="/some-namespace/myAction" executeResult="true"/>
> >> </div>
> >>
> >> And a struts.xml file that defines a package with the namespace
> >> 'some-namespace' that contains an action called myAction I see no call
> to
> >> the target action (I am debugging and have a breakpoint in my action). I
> >> simply get a blank space in my output. However if I past a full url in
> my
> >> browser e.g. http://x.y.org/myApp/some-namespace/myAction.action all is
> >> well.
> >
> > Yeah, that's a little weird. If you turn up the logging is there anything
> > on
> > the console? I mean, clearly it'll work w/ the proper use of the
> > "namespace"
> > attribute etc. but something on the console might be handy if it isn't
> > already there.
> >
> > Dave
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > For additional commands, e-mail: user-help@(protected)
> >
> >
> >
>
> --
> View this message in context:
>
http://www.nabble.com/actions-defined-in-a-package-are-visible-in-other-packages---tp11277458p15242369.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

Attachment:
user_182152.ezm (zipped)Dave,
Thanks for the help here. I see the same thing happening now.
If I have a leading slash in my config file I can create a link with both
and action and a url but the action tag then only works if I have a leading
slash. If I dont then I get the 'cannot find action' error.
I can create a url tag with or without a leading slash.
If I dont have a leading slash in the namespace attribute in the config file
I cannot create a url at all.
It may be inconsistent. It maybe documented that way. It may be the case
that this demonstrates the correct semantics for both the url and action
tags, I don't know. I do know that I can make progress now and that makes me
happy.
I do wonder if this is correct. I am gonna have a good long look at docs
again and see.
Thanks all for the feedback. Especially Dave N.
Paul B.
newton.dave wrote:
>
> I can only dupe this if I leave out the leading "/" (slash) in my
> namespace
> attribute of my package.
>
> Off the top of my head I'd say that the dispatcher is looking in a "/"
> namespace (as opposed to the "" (empty string) namespace) and can't find
> the
> action there (or is looking in "" instead of "/", maybe).
>
> If you use the leading "/" in your namespace attribute (both in your S2
> config file and in the tags) it should work. (Although I just tried it
> only
> in config and not in the tag and that worked too, but I wouldn't recommend
> it.)
>
> Dave
>
> --- paulbrickell <paul.brickell@(protected):
>
>>
>> Dave,
>>
>> OK did as you suggested, cranked up the logging level and I do now get
>> some
>> logging. I created a little sandbox app to test out some things with and
>> simplifying has really helped. Heres what I have now
>>
>> <div>
>> <s:action name="test" namespace="secondary" executeResult="true"/>
>> </div>
>> <div>
>> <s:action name="secondary/test.action" executeResult="true"/>
>> </div>
>> <div>
>> <s:url id="testUrlId" namespace="secondary" action="test"/>
>> <s:a href="%{testUrlId}">execute test action</s:a>
>> </div>
>>
>>
>> Now the first div works exactly as expected.
>>
>> The second one also works how would expect it to. It Always generates a
>> stack trace with the error message "There is no Action mapped for action
>> name secondary/test.ation" regardless of how I try to specify the 'path'
>> to
>> the action. Now I know that the namespace does not represent a path and
>> that
>> I need to use the namespace attribute. I think thats fine and that
>> doesn't
>> give me any kind of problem. I can always specify the namespace attribute
>> and all is well.
>>
>> But the third div is my problem. There seems to be no way a can form a
>> URL
>> for s:a tag that lets me build a link to the namespaced action. The link
>> directs the browser to...
>>
>> http://localhost:8080/sandbox/secondary/test.action
>>
>> That seems ok to me. but when I click this link I get this...
>>
>> [example] DEBUG [http-8080-1] DefaultActionProxy.<init>(65) | Creating an
>> DefaultActionProxy for namespace and action name test
>> [example] ERROR [http-8080-1] Dispatcher.serviceAction(512) | Could not
>> find
>> action or result
>> There is no Action mapped for action name test. - [unknown location]
>> at
>>
>
com.opensymphony.xwork2.DefaultActionProxy.prepare (
DefaultActionProxy.java:186)
>> at
>>
>
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy (
StrutsActionProxyFactory.java:41)
>> at
>>
org.apache.struts2.dispatcher.Dispatcher.serviceAction (
Dispatcher.java:494)
>> at
>>
>
org.apache.struts2.dispatcher.FilterDispatcher.doFilter (
FilterDispatcher.java:419)
>> 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:175)
>> 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:263)
>> at
>>
org.apache.coyote.http11.Http11Processor.process (
Http11Processor.java:844)
>> at
>>
>
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
>> at
>>
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>> at
java.lang.Thread.run(Unknown Source)
>>
>>
>> (Hope its OK to dump stacktraces here, apologies if its bad form).
>>
>> it seems from the debug line "[example] DEBUG [http-8080-1]
>> DefaultActionProxy.<init>(65) | Creating an DefaultActionProxy for
>> namespace
>> and action name test" That there is no namespace defined. I will try to
>> step
>> throught the DefaultActionProxy next to find out why that might be.
>>
>> If thats correct (the link represents a path after all), am I going to
>> have
>> to have all my links in the root namespace? I can do this of course, but
>> it
>> seems a ilttle restrictive.
>>
>> Just have to say thanks for all the feedback. I am always impressed with
>> the
>> help given on these lists.
>>
>> Paul B.
>>
>>
>>
>> newton.dave wrote:
>> >
>> > --- paulbrickell <paul.brickell@(protected):
>> >> I don't think I was clear about what I am seeing. If I have an action
>> tag
>> >> in my page like this...
>> >>
>> >> <div>
>> >> <s:action name="/some-namespace/myAction" executeResult="true"/>
>> >> </div>
>> >>
>> >> And a struts.xml file that defines a package with the namespace
>> >> 'some-namespace' that contains an action called myAction I see no call
>> to
>> >> the target action (I am debugging and have a breakpoint in my action).
>> I
>> >> simply get a blank space in my output. However if I past a full url in
>> my
>> >> browser e.g. http://x.y.org/myApp/some-namespace/myAction.action all
>> is
>> >> well.
>> >
>> > Yeah, that's a little weird. If you turn up the logging is there
>> anything
>> > on
>> > the console? I mean, clearly it'll work w/ the proper use of the
>> > "namespace"
>> > attribute etc. but something on the console might be handy if it isn't
>> > already there.
>> >
>> > Dave
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@(protected)
>> > For additional commands, e-mail: user-help@(protected)
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>>
> http://www.nabble.com/actions-defined-in-a-package-are-visible-in-other-packages---tp11277458p15242369.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_182139.ezm (zipped)--- Arun <arun.george.1981@(protected):
> I am using tomcat. Is it possible implement container managed security with
this?
Yes; see the Tomcat docs[1,2].
Dave
[1] http://tomcat.apache.org/tomcat-5.5-doc/realm-howto.html
[2] http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html
>
> On Feb 1, 2008 7:42 PM, Cory D. Wiles <kwylez@(protected):
>
> > At my job we authenticate our users directly using Active Directory using
> > container managed security.
> >
> > What container are you using?
> >
> > On Feb 1, 2008 4:48 AM, Antonio Petrelli <antonio.petrelli@(protected)>
> > wrote:
> >
> > > 2008/2/1, Arun <arun.george.1981@(protected)>:
> > > > Hi,
> > > >
> > > > I have a web application in which I need to implement windows
> > > > authentication.
> > > > Basically there is a login screen where we can enter username and
> > > password.
> > > > These users are the users that are there in OS.
> > > > The username is like domainname\username and password is the
> password.
> > > > A basic authentication dialog wil popup asking this. It should
> > > authenticate
> > > > against the domain name server.
> > > > And forward to home page with the login information.
> > > > Can anybody help me on this.?
> > >
> > > This may help you a lot:
> > > http://jcifs.samba.org/src/docs/ntlmhttpauth.html
> > >
> > > Ciao
> > > Antonio
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@(protected)
> > > For additional commands, e-mail: user-help@(protected)
> > >
> > >
> >
> >
> > --
> > Cory Wiles
> > kwylez@(protected)
> > http://www.corywiles.com
> > http://alphaprevails.blogspot.com
> >
>
>
>
> --
> Thanks
> Arun George
>

Attachment:
user_182141.ezm (zipped)
Hi,
I am trying to reset a validator form after the form is submitted and a few
of the validations have failed.
Reset button used in the form clears out fields changed only since the time
the form is loaded. That is it does just the client side reset. One way that
i figured out was to submit the form back to the jsp so that the jsp reloads
with all the form field reinitialized.
Is there some other method of clearing out the form fields after it has
failed the validations defined in validation.xml?
Thanks in advance for all the valuable suggestions!
Ashima Beri
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_182145.ezm (zipped)Ashima Beri wrote:
> Hi,
> I am trying to reset a validator form after the form is submitted and a few
> of the validations have failed.
> Reset button used in the form clears out fields changed only since the time
> the form is loaded. That is it does just the client side reset. One way that
> i figured out was to submit the form back to the jsp so that the jsp reloads
> with all the form field reinitialized.
> Is there some other method of clearing out the form fields after it has
> failed the validations defined in validation.xml?
> Thanks in advance for all the valuable suggestions!
> Ashima Beri
Do you want to clear out the form fields before redisplaying the form
after a validation error, or just allow the user to request a reset
after the form is redisplayed?
Usually you would want to retain the data the user input after a
validation failure, so they can correct mistakes without having to fill
the entire form in again. If you really want to reset the form to its
starting state before redisplaying, discarding the user's input, then
you would need to do that in your validate() method (remember, if you
don't already have a validate() method, that when you add one it needs
to call super.validate() to trigger the XML-based validation).
If you just want to provide a button the user can click to reset the
form, a 'submit' button and round trip through your action is the
correct way to do so. As you've realized, a 'reset' button just tells
the browser to restore the input values it received the last time the
form was loaded.
L.

Attachment:
user_182147.ezm (zipped)
Hi Laurie,
Thanks for the quick reply.
I want to reset the form fields after hitting a reset button.
When I thought of going about it through the Action class way and tried to
clear out my form fields , strangely i noticed that the Action class's
execute method is never called if there are still certain validations
failing.
I read in struts flow explanation that Action class is only called if the
validations are passed through.
I dont know what other way to adopt.
Any suggestions?
Thanks
Ashima Beri
Laurie Harper wrote:
>
> Ashima Beri wrote:
>> Hi,
>> I am trying to reset a validator form after the form is submitted and a
>> few
>> of the validations have failed.
>> Reset button used in the form clears out fields changed only since the
>> time
>> the form is loaded. That is it does just the client side reset. One way
>> that
>> i figured out was to submit the form back to the jsp so that the jsp
>> reloads
>> with all the form field reinitialized.
>> Is there some other method of clearing out the form fields after it has
>> failed the validations defined in validation.xml?
>> Thanks in advance for all the valuable suggestions!
>> Ashima Beri
>
> Do you want to clear out the form fields before redisplaying the form
> after a validation error, or just allow the user to request a reset
> after the form is redisplayed?
>
> Usually you would want to retain the data the user input after a
> validation failure, so they can correct mistakes without having to fill
> the entire form in again. If you really want to reset the form to its
> starting state before redisplaying, discarding the user's input, then
> you would need to do that in your validate() method (remember, if you
> don't already have a validate() method, that when you add one it needs
> to call super.validate() to trigger the XML-based validation).
>
> If you just want to provide a button the user can click to reset the
> form, a 'submit' button and round trip through your action is the
> correct way to do so. As you've realized, a 'reset' button just tells
> the browser to restore the input values it received the last time the
> form was loaded.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_182148.ezm (zipped)--- Ashima Beri <ashima.beri@(protected):
> I read in struts flow explanation that Action class is only called if the
> validations are passed through.
> I dont know what other way to adopt.
What Laurie is saying is that you can implement a validate() method and call
super.validate() before you do your custom processing (which seems to
include clearing out all form values?)
You can check to see if there were validation errors the same way the
workflow interceptor does; by checking for the presence of error messages.
Dave

Attachment:
user_182149.ezm (zipped)On a normal form submit to an action with validation, if validation
fails, the request is forwarded to the input result and execute() is
bypassed, yes. So, you have two options:
1) as Dave reiterated, you can put your form reset logic in validate();
have your validate method detect the when the reset submit button was
pressed and, if so, clear the form.
2) use a 'cancel' button as the reset submit. A cancel button will (if
you configure the action appropriately) bypass validation and call
directly into your execute() method.
For my money, option 2 is the better approach, since cluttering
validate() with non-validation concerns smells a bit... :p)
L.
Ashima Beri wrote:
> Hi Laurie,
> Thanks for the quick reply.
> I want to reset the form fields after hitting a reset button.
> When I thought of going about it through the Action class way and tried to
> clear out my form fields , strangely i noticed that the Action class's
> execute method is never called if there are still certain validations
> failing.
> I read in struts flow explanation that Action class is only called if the
> validations are passed through.
> I dont know what other way to adopt.
> Any suggestions?
> Thanks
> Ashima Beri
>
>
> Laurie Harper wrote:
>> Ashima Beri wrote:
>>> Hi,
>>> I am trying to reset a validator form after the form is submitted and a
>>> few
>>> of the validations have failed.
>>> Reset button used in the form clears out fields changed only since the
>>> time
>>> the form is loaded. That is it does just the client side reset. One way
>>> that
>>> i figured out was to submit the form back to the jsp so that the jsp
>>> reloads
>>> with all the form field reinitialized.
>>> Is there some other method of clearing out the form fields after it has
>>> failed the validations defined in validation.xml?
>>> Thanks in advance for all the valuable suggestions!
>>> Ashima Beri
>> Do you want to clear out the form fields before redisplaying the form
>> after a validation error, or just allow the user to request a reset
>> after the form is redisplayed?
>>
>> Usually you would want to retain the data the user input after a
>> validation failure, so they can correct mistakes without having to fill
>> the entire form in again. If you really want to reset the form to its
>> starting state before redisplaying, discarding the user's input, then
>> you would need to do that in your validate() method (remember, if you
>> don't already have a validate() method, that when you add one it needs
>> to call super.validate() to trigger the XML-based validation).
>>
>> If you just want to provide a button the user can click to reset the
>> form, a 'submit' button and round trip through your action is the
>> correct way to do so. As you've realized, a 'reset' button just tells
>> the browser to restore the input values it received the last time the
>> form was loaded.
>>
>> L.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>> For additional commands, e-mail: user-help@(protected)
>>
>>
>>
>

Attachment:
user_182150.ezm (zipped)
Thanks Laurie...
This helps!
Ill go the secod way.
Laurie Harper wrote:
>
> On a normal form submit to an action with validation, if validation
> fails, the request is forwarded to the input result and execute() is
> bypassed, yes. So, you have two options:
>
> 1) as Dave reiterated, you can put your form reset logic in validate();
> have your validate method detect the when the reset submit button was
> pressed and, if so, clear the form.
>
> 2) use a 'cancel' button as the reset submit. A cancel button will (if
> you configure the action appropriately) bypass validation and call
> directly into your execute() method.
>
> For my money, option 2 is the better approach, since cluttering
> validate() with non-validation concerns smells a bit... :p)
>
> L.
>
> Ashima Beri wrote:
>> Hi Laurie,
>> Thanks for the quick reply.
>> I want to reset the form fields after hitting a reset button.
>> When I thought of going about it through the Action class way and tried
>> to
>> clear out my form fields , strangely i noticed that the Action class's
>> execute method is never called if there are still certain validations
>> failing.
>> I read in struts flow explanation that Action class is only called if the
>> validations are passed through.
>> I dont know what other way to adopt.
>> Any suggestions?
>> Thanks
>> Ashima Beri
>>
>>
>> Laurie Harper wrote:
>>> Ashima Beri wrote:
>>>> Hi,
>>>> I am trying to reset a validator form after the form is submitted and a
>>>> few
>>>> of the validations have failed.
>>>> Reset button used in the form clears out fields changed only since the
>>>> time
>>>> the form is loaded. That is it does just the client side reset. One way
>>>> that
>>>> i figured out was to submit the form back to the jsp so that the jsp
>>>> reloads
>>>> with all the form field reinitialized.
>>>> Is there some other method of clearing out the form fields after it has
>>>> failed the validations defined in validation.xml?
>>>> Thanks in advance for all the valuable suggestions!
>>>> Ashima Beri
>>> Do you want to clear out the form fields before redisplaying the form
>>> after a validation error, or just allow the user to request a reset
>>> after the form is redisplayed?
>>>
>>> Usually you would want to retain the data the user input after a
>>> validation failure, so they can correct mistakes without having to fill
>>> the entire form in again. If you really want to reset the form to its
>>> starting state before redisplaying, discarding the user's input, then
>>> you would need to do that in your validate() method (remember, if you
>>> don't already have a validate() method, that when you add one it needs
>>> to call super.validate() to trigger the XML-based validation).
>>>
>>> If you just want to provide a button the user can click to reset the
>>> form, a 'submit' button and round trip through your action is the
>>> correct way to do so. As you've realized, a 'reset' button just tells
>>> the browser to restore the input values it received the last time the
>>> form was loaded.
>>>
>>> L.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@(protected)
>>> For additional commands, e-mail: user-help@(protected)
>>>
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_182151.ezm (zipped)
Thanks Dave! This explains it.
newton.dave wrote:
>
> --- Ashima Beri <ashima.beri@(protected):
>> I read in struts flow explanation that Action class is only called if the
>> validations are passed through.
>> I dont know what other way to adopt.
>
> What Laurie is saying is that you can implement a validate() method and
> call
> super.validate() before you do your custom processing (which seems to
> include clearing out all form values?)
>
> You can check to see if there were validation errors the same way the
> workflow interceptor does; by checking for the presence of error messages.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_182142.ezm (zipped)How I can intercept *before* session delete event?

Attachment:
user_182146.ezm (zipped)Sergey Livanov wrote:
> How I can intercept *before* session delete event?
HttpSessionListener.sessionDestroyed():
Notification that a session is about to be invalidated.
http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpSessionListener.html
L.

Attachment:
user_182143.ezm (zipped)It works fine for me too. Maybe it's a problem with the version of Maven
you're using?
[laurie@(protected)
Maven version: 2.0.6
[laurie@(protected)
-DartifactId=struts2-example -DarchetypeGroupId=org.apache.struts
-DarchetypeArtifactId=struts2-archetype-starter
-DarchetypeVersion=2.0.11
-DremoteRepositories=http://people.apache.org/builds/struts/m2-staging-repository
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO]
----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [archetype:create] (aggregator-style)
[INFO]
----------------------------------------------------------------------------
[INFO] Setting property: classpath.resource.loader.class =>
'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] **************************************************************
[INFO] Starting Jakarta Velocity v1.4
[INFO] RuntimeInstance initializing.
[INFO] Default Properties File:
org/apache/velocity/runtime/defaults/velocity.properties
[INFO] Default ResourceManager initializing. (class
org.apache.velocity.runtime.resource.ResourceManagerImpl)
[INFO] Resource Loader Instantiated:
org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader
[INFO] ClasspathResourceLoader : initialization starting.
[INFO] ClasspathResourceLoader : initialization complete.
[INFO] ResourceCache : initialized. (class
org.apache.velocity.runtime.resource.ResourceCacheImpl)
[INFO] Default ResourceManager initialization complete.
[INFO] Loaded System Directive:
org.apache.velocity.runtime.directive.Literal[INFO] Loaded System Directive:
org.apache.velocity.runtime.directive.Macro[INFO] Loaded System Directive:
org.apache.velocity.runtime.directive.Parse[INFO] Loaded System Directive:
org.apache.velocity.runtime.directive.Include[INFO] Loaded System Directive:
org.apache.velocity.runtime.directive.Foreach[INFO] Created: 20 parsers.
[INFO] Velocimacro : initialization starting.
[INFO] Velocimacro : adding VMs from VM library template :
VM_global_library.vm
[ERROR] ResourceManager : unable to find resource 'VM_global_library.vm'
in any resource loader.
[INFO] Velocimacro : error using VM library template
VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'VM_global_library.vm'
[INFO] Velocimacro : VM library template macro registration complete.
[INFO] Velocimacro : allowInline = true : VMs can be defined inline in
templates
[INFO] Velocimacro : allowInlineToOverride = false : VMs defined inline
may NOT replace previous VM definitions
[INFO] Velocimacro : allowInlineLocal = false : VMs defined inline will
be global in scope if allowed.
[INFO] Velocimacro : initialization complete.
[INFO] Velocity successfully started.
[INFO] [archetype:create]
[INFO] Defaulting package to group ID: home.struts2
[INFO] We are using command line specified remote repositories:
http://people.apache.org/builds/struts/m2-staging-repository
[INFO]
----------------------------------------------------------------------------
[INFO] Using following parameters for creating Archetype:
struts2-archetype-starter:2.0.11
[INFO]
----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: home.struts2
[INFO] Parameter: packageName, Value: home.struts2
[INFO] Parameter: basedir, Value: /Users/laurie/tmp/x
[INFO] Parameter: package, Value: home.struts2
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: artifactId, Value: struts2-example
[INFO] ********************* End of debug info from resources from
generated POM ***********************
[WARNING]
org.apache.velocity.runtime.exception.ReferenceException:
reference : template =
archetype-resources/src/main/java/HelloWorldAction.java [line 2,column
4] : $Id is not a valid reference.
[WARNING]
org.apache.velocity.runtime.exception.ReferenceException:
reference : template =
archetype-resources/src/main/java/IndexAction.java [line 2,column 4] :
$Id is not a valid reference.
[WARNING]
org.apache.velocity.runtime.exception.ReferenceException:
reference : template =
archetype-resources/src/main/java/DateConverter.java [line 2,column 4] :
$Id is not a valid reference.
[WARNING]
org.apache.velocity.runtime.exception.ReferenceException:
reference : template =
archetype-resources/src/main/webapp/WEB-INF/sitemesh.xml [line 5,column
21] : ${decorators-file} is not a valid reference.
[WARNING]
org.apache.velocity.runtime.exception.ReferenceException:
reference : template =
archetype-resources/src/main/webapp/WEB-INF/sitemesh.xml [line 45,column
41] : ${decorators-file} is not a valid reference.
[WARNING]
org.apache.velocity.runtime.exception.ReferenceException:
reference : template =
archetype-resources/src/test/java/HelloWorldActionTest.java [line
2,column 4] : $Id is not a valid reference.
[WARNING]
org.apache.velocity.runtime.exception.ReferenceException:
reference : template =
archetype-resources/src/test/java/IndexActionTest.java [line 2,column 4]
: $Id is not a valid reference.
[INFO] Archetype created in dir: /Users/laurie/tmp/x/struts2-example
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Sat Feb 02 12:39:44 EST 2008
[INFO] Final Memory: 5M/9M
[INFO]
------------------------------------------------------------------------
Nuwan Chandrasoma wrote:
> Hi,
>
> The command i have given to you work for me, i dont know what is wrong
> here.. any maven guru can help you on this.
>
> Thanks,
>
> Nuwan
> (http://code.google.com/p/struts2-ssl-plugin/)
>
> Thai Dang Vu wrote:
>> I tried what you suggested, but still got error:
>>
>> mvn -e archetype:create -DgroupId=home.struts2
>> -DartifactId=struts2-example -DarchetypeGroupId=org.apache.struts
>> -DarchetypeArtifactId=struts2-archetype-starter
>> -DarchetypeVersion=2.0.11
>> -DremoteRepositories=http://people.apache.org/builds/struts/m2-staging-repository
>>
>> + Error stacktraces are turned on.
>> [INFO] Scanning for projects...
>> [INFO] Searching repository for plugin with prefix: 'archetype'.
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Building Maven Default Project
>> [INFO] task-segment: [archetype:create] (aggregator-style)
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Setting property: classpath.resource.loader.class =>
>> 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
>> [INFO] Setting property: velocimacro.messages.on => 'false'.
>> [INFO] Setting property: resource.loader => 'classpath'.
>> [INFO] Setting property: resource.manager.logwhenfound => 'false'.
>> [INFO] **************************************************************
>> [INFO] Starting Jakarta Velocity v1.4
>> [INFO] RuntimeInstance initializing.
>> [INFO] Default Properties File:
>> org/apache/velocity/runtime/defaults/velocity.properties
>> [INFO] Default ResourceManager initializing. (class
>>
org.apache.velocity.runtime.resource.ResourceManagerImpl)
>> [INFO] Resource Loader Instantiated:
>> org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader
>> [INFO] ClasspathResourceLoader : initialization starting.
>> [INFO] ClasspathResourceLoader : initialization complete.
>> [INFO] ResourceCache : initialized. (class
>>
org.apache.velocity.runtime.resource.ResourceCacheImpl)
>> [INFO] Default ResourceManager initialization complete.
>> [INFO] Loaded System Directive:
>>
org.apache.velocity.runtime.directive.Literal>> [INFO] Loaded System Directive:
>>
org.apache.velocity.runtime.directive.Macro>> [INFO] Loaded System Directive:
>>
org.apache.velocity.runtime.directive.Parse>> [INFO] Loaded System Directive:
>>
org.apache.velocity.runtime.directive.Include>> [INFO] Loaded System Directive:
>>
org.apache.velocity.runtime.directive.Foreach>> [INFO] Created: 20 parsers.
>> [INFO] Velocimacro : initialization starting.
>> [INFO] Velocimacro : adding VMs from VM library template :
>> VM_global_library.vm
>> [ERROR] ResourceManager : unable to find resource
>> 'VM_global_library.vm' in any resource loader.
>> [INFO] Velocimacro : error using VM library template
>> VM_global_library.vm :
>>
org.apache.velocity.exception.ResourceNotFoundException: Unable to
>> find resource 'VM_global_library.vm'
>> [INFO] Velocimacro : VM library template macro registration complete.
>> [INFO] Velocimacro : allowInline = true : VMs can be defined inline in
>> templates
>> [INFO] Velocimacro : allowInlineToOverride = false : VMs defined
>> inline may NOT replace previous VM definitions
>> [INFO] Velocimacro : allowInlineLocal = false : VMs defined inline
>> will be global in scope if allowed.
>> [INFO] Velocimacro : initialization complete.
>> [INFO] Velocity successfully started.
>> [INFO] [archetype:create]
>> [INFO] Defaulting package to group ID: home.struts2
>> [INFO] We are using command line specified remote repositories:
>> http://people.apache.org/builds/struts/m2-staging-repository
>> Downloading:
>> http://people.apache.org/builds/struts/m2-staging-repository/org/apache/struts/struts2-archetype-starter/2.0.11/struts2-archetype-starter-2.0.11.jar
>>
>> [INFO]
>> ------------------------------------------------------------------------
>> [ERROR] BUILD ERROR
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Error creating from archetype
>>
>> Embedded error: Archetype does not exist.
>> Unable to download the artifact from any repository
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Trace
>>
org.apache.maven.lifecycle.LifecycleExecutionException: Error creating
>> from archetype
>> at
>>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals (
DefaultLifecycleExecutor.java:564)
>>
>> at
>>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal (
DefaultLifecycleExecutor.java:493)
>>
>> at
>>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal (
DefaultLifecycleExecutor.java:463)
>>
>> at
>>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures (
DefaultLifecycleExecutor.java:311)
>>
>> at
>>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments (
DefaultLifecycleExecutor.java:224)
>>
>> at
>>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute (
DefaultLifecycleExecutor.java:143)
>>
>> at
org.apache.maven.DefaultMaven.doExecute (
DefaultMaven.java:333)
>> at
org.apache.maven.DefaultMaven.execute (
DefaultMaven.java:126)
>> at
org.apache.maven.cli.MavenCli.main (
MavenCli.java:282)
>> at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>>
sun.reflect.NativeMethodAccessorImpl.invoke (
NativeMethodAccessorImpl.java:39)
>>
>> at
>>
sun.reflect.DelegatingMethodAccessorImpl.invoke (
DelegatingMethodAccessorImpl.java:25)
>>
>> at
java.lang.reflect.Method.invoke (
Method.java:597)
>> at
>> org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>> at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>> at
>> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>> at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
>> Caused by:
org.apache.maven.plugin.MojoExecutionException: Error
>> creating from archetype
>> at
>> org.apache.maven.plugin.archetype.MavenArchetypeMojo.execute(MavenArchetypeMojo.java:229)
>>
>> at
>>
org.apache.maven.plugin.DefaultPluginManager.executeMojo (
DefaultPluginManager.java:447)
>>
>> at
>>
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals (
DefaultLifecycleExecutor.java:539)
>>
>> ... 16 more
>> Caused by: org.apache.maven.archetype.ArchetypeNotFoundException:
>> Archetype does not exist.
>> at
>> org.apache.maven.archetype.DefaultArchetype.createArchetype(DefaultArchetype.java:130)
>>
>> at
>> org.apache.maven.plugin.archetype.MavenArchetypeMojo.execute(MavenArchetypeMojo.java:224)
>>
>> ... 18 more
>> Caused by:
>> org.apache.maven.shared.downloader.DownloadNotFoundException:
>> Requested download does not exist.
>> at
>> org.apache.maven.shared.downloader.DefaultDownloader.download(DefaultDownloader.java:62)
>>
>> at
>> org.apache.maven.archetype.DefaultArchetype.createArchetype(DefaultArchetype.java:121)
>>
>> ... 19 more
>> Caused by:
>>
org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable
>> to download the artifact from any repository
>>
>> Try downloading the file manually from the project website.
>>
>> Then, install it using the command: mvn install:install-file
>> -DgroupId=org.apache.struts -DartifactId=struts2-archetype-starter
>> -Dversion=2.0.11 -Dpackaging=jar -Dfile=/path/to/file
>>
>> Alternatively, if you host your own repository you can deploy the file
>> there: mvn deploy:deploy-file -DgroupId=org.apache.struts
>> -DartifactId=struts2-archetype-starter -Dversion=2.0.11
>> -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
>>
>> Hi,
>>
>> mvn archetype:create -DgroupId=com.s2.anu -DartifactId=s2proj
>> -DarchetypeGroupId=org.apache.struts-DarchetypeArtifactId=struts2-archetype-starter
>>
>> -DarchetypeVersion=
>> 2.0.11 -DremoteRepositories=
>> http://people.apache.org/builds/struts/m2-staging-repository
>>
>> why dont you try this. i think this might work.
>>
>> Thanks,
>>
>> Nuwan
>> (http://code.google.com/p/struts2-ssl-plugin/)
>>
>>
>>
>>
>> ____________________________________________________________________________________
>>
>> Looking for last minute shopping deals? Find them fast with Yahoo!
>> Search.
>> http://tools.search.yahoo.com/newsearch/category.php?category=shopping
>>

Attachment:
user_182144.ezm (zipped)Mike J. M. wrote:
> Hello,
>
>
> So I am currently using Struts, including an action that has a fileUpload
> Interceptor that checks for files that are too large and certain allowable
> file types. Right now if either of these conditions are met, the system will
> throw a generic HTTP 500 error up. What I am wondering is how to customize
> this.
>
>
> in the docs:
> http://struts.apache.org/2.0.6/struts2-core/apidocs/org/apache/struts2/interceptor/FileUploadInterceptor.html
>
> i found these messages that i can supposedly customize. however, the doc
> does not specify WHERE i am supposed to put these error messages at, and
> furthermore, after looking at the source code for FileUploadInterceptor, I
> found that these messages are printed to the log file, and it doesn't look
> like it prints to the actual HTML.
>
>
> * struts.messages.error.uploading - a general error that occurs when the
> file could not be uploaded
>
>
> * struts.messages.error.file.too.large - occurs when the uploaded file is
> too large
>
>
> * struts.messages.error.content.type.not.allowed - occurs when the uploaded
> file does not match the expected content types specified
>
>
> The doc says that these error messages originate from
> struts-messages.properties. I'm guessing that's in the struts.jar itself
> because I don't see it anywhere else, so am I supposed to modify that
> directly? I'm a little bit iffy about doing that.
It's not obvious from the documentation, but the message come from the
'global message resources', which you configure via the
struts.custom.i18n.resources property in struts.properties. The
struts=messages.properties file mentioned is where the standard defaults
are stored.
So, create a resource bundle containing your customized error messages,
say my-struts-messages.properties, and place it in the classpath, then
add a struts.custom.i18n.resources=package.name.my-struts-messaes
property to your struts.properties configuration.
> So, in a nutshell, how do I catch an Interceptor error and make it redirect
> to a nice page instead of the generic HTTP 500 page? Actually, what would be
> better is to redirect to an action while passing into it a parameter
> "message" that will contain error messages. Then, in the JSP i want to do
> <s:property ...> to grab that message.
I'm not sure about this part. I would expect, assuming you implement
ValidationAware (e.g. by extending from ActionSupport), that you would
get a validation failure rather than a status 500 response. If you're
still experiencing that, post the corresponding error logs and stack trace.
L.

Attachment:
user_182153.ezm (zipped)
thank you nagesh. the link s very much helpfull to acheive my task.
nagesh.kumar wrote:
>
> I think some more components like table ,tabbedPanel ,tree ,treenode
> which
> are look like datarid we can use this
>
>
> http://struts.apache.org/2.0.6/docs/tag-reference.html
>
>
> Thanks
> Nagesh Reddy
>
> -----Original Message-----
> From: mansour77@(protected)]
> Sent: Friday, March 23, 2007 7:22 AM
> To: user@(protected)
> Subject: DataGrid, Struts layout and Struts 2
>
> Hello every one:
> I am looking for a way to pass a resultSet or cachedRowSet to a jsp page,
> and display the results in a dataGrid.
> The behavior I am looking for is similar to the one offered by Struts
> Layout
> http://struts.application-servers.com/intro/layout.html.
> Unforetunatly Struts-Layout doesn't work with Struts 2. So I need an
> alternative. Can any one help ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
> DISCLAIMER:
> The information in this e-mail is the property of InterGlobe and is
> confidential and privileged. It is intended solely for the addressee.
> Access to this email by anyone else is unauthorized. If you are not the
> intended recipient, any disclosure, copying, distribution or any action
> taken in reliance on it is prohibited and will be unlawful. If you receive
> this message in error, please notify the sender immediately and delete all
> copies of this message
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
--
Sent from the Struts - User mailing list archive at Nabble.com.

Attachment:
user_182154.ezm (zipped)Jeromy,
Thanks for the comprehensive reply. Looking at the documentation and the
example app, I am still not sure how to configure my action/response. I
am using tiles 2.
If I configure the autocompleter as such:
<s:label name="text" value="Search for Question Text:" />
<s:url id="search" namespace="/question"
value="/question/searchByText.action" />
<s:autocompleter theme="ajax" href="%{search}" name="text"
loadOnTextChange="true" loadMinimumCount="3"/>
It seems I need to return my result in JSON format correct? By returning
a JSON String from the action, how to I configure my response?
<action name="searchByText" method="searchByText"
class="gov.hhs.fda.datacall.web.struts.action.QuestionAction">
<result name="success" type="tiles">question.panel</result>
</action>
If I use the tiles response type, I get a dojo parsing error because the
whole page is returned from the reply.
The example in the example app isn't very clear to me, as the action
returns a .JS file with the result hard coded, and not using any
template like tiles I might add.
Also, I think I found a bug? -- the namespace attribute seems to be
ignored when I pass href=%{search} to the autocompleter. I had to put
qualify the namespace in the value to get the correct action to be
invoked.
Any further assistance you might provide would be much appreciated...
MG
-----Original Message-----
From: Jeromy Evans [mailto:jeromy.evans@(protected)]
Sent: Friday, February 01, 2008 6:36 PM
To: Struts Users Mailing List
Subject: Re: AjaxTag 1.3 support?
My 2c:
I think this is a bad solution and shouldn't be encouraged. It's
marginally better than writing a custom servlet.
Struts2 ResultTypes [1] are designed specifically for controlling the
type and content of results from actions to separate the view from the
model, even if the "view" is XML data. Accessing the response and
writing to it directly isn't necessary except in the rarest of cases.
For Ajax/JS libraries that use JSON, the JSON Plugin (JSON ResultType)
[2] will serialize your action into JSON automatically
The XSL ResultType will serialize your action into XML if you provide a
stylesheet [3]
The REST plugin includes code to serialize your action into XML using
Xstream. [4]
My point is, your action can setup a model (eg. a javabean matching the
model expected by AjaxTag), and the ResultType can serialize it to the
output stream. In this case I'd create a custom result type using
XStream, but you could also use a XML template in a Tile, or have a
ResultType that accesses the instance created by AjaxXMLBuilder.
[1] http://struts.apache.org/2.0.11/docs/result-types.html
[2] http://cwiki.apache.org/S2PLUGINS/json-plugin.html
[3] http://struts.apache.org/2.0.11/docs/xsl-result.html
[4] http://xstream.codehaus.org/
[5] http://struts.apache.org/2.0.11/docs/result-configuration.html
regards
Jeromy Evans
Hodgins, Grant wrote:
> I was able to get the AjaxTags stuff working (with Tiles2 although I
don't think that matters at all).
>
> As Dave said, your action should return null since you want the action
to return XML in the response.
>
> Instead, in addition to returning a null result, I simply wrote the
xml to the response:
>
> AjaxXmlBuilder xml = new AjaxXmlBuilder();
>
> ... build your xml response ...
>
> response.setContentType("text/xml; charset=iso-8859-1");
> response.setHeader("Cache-Control", "no-store, max-age=0, no-cache,
must-revalidate");
> response.addHeader("Cache-Control", "post-check=0, pre-check=0");
> response.setHeader("Pragma", "no-cache");
>
> PrintWriter pw = response.getWriter();
> pw.write(xml.toString());
> pw.close();
>
> Hope this helps.
>
> Grant
>
> ________________________________
>
> From: Griffith, Michael * [mailto:Michael.Griffith@(protected)]
> Sent: Fri 2/1/2008 3:48 PM
> To: Struts Users Mailing List
> Subject: RE: AjaxTag 1.3 support?
>
>
>
> Dave,
>
> Thanks for the reply. I guess I should have said freemarker instead of
> sitemesh...? At any rate, when the docs don't match the release, it's
a
> bad thing.
>
> I shouldn't need to do any of this should I? Can you point me at a
> simple, minimalist example of the <s:autocompleter> tag?
>
> mg
>
> -----Original Message-----
> From: Dave Newton [mailto:newton.dave@(protected)]
> Sent: Friday, February 01, 2008 5:42 PM
> To: Struts Users Mailing List
> Subject: Re: AjaxTag 1.3 support?
>
> --- "Griffith, Michael *" <Michael.Griffith@(protected):
>
>> public class QuestionAction extends BaseAction implements
>> ModelDriven<Question>, Preparable, ServletRequestAware,
>> ServletResponseAware {
>> public String getSearchTerm() throws Exception {
>> System.out.println("**** Question Search Term:" + qt);
>> List<Question> results=
>>
> questionService.getQuestions(qt);
>
>> AjaxXmlBuilder builder= new AjaxXmlBuilder();
>> builder.addItems(results, "questionType", "text");
>>
>> response.setContentType("text/xml");
>> response.setHeader("Cache-Control", "no-cache");
>> ServletOutputStream out = response.getOutputStream();
>> out.print(builder.toString());
>> out.close();
>>
>> return SUCCESS;
>> }
>>
>> My struts mapping:
>>
>> <package name="question" extends="base-pkg"
>> namespace="/question">
>> <action name="get-term" method="getSearchTerm"
>> class="...QuestionAction">
>> <result name="success"
>> type="tiles">question.panel</result>
>> </action>
>> </package>
>>
>
> If you're writing directly to the stream I doubt you'd even want to
> return
> anything other than a null from the action, no? What is the
> "question.panel"
> tile?
>
>
>> The struts 2 Ajax documentation seems manic and dated. It seems the
S2
>> Ajax implementation is tied closely to sitemesh, which I am not
using.
>>
>
> SiteMesh? The Ajax implementation isn't tied to SiteMesh at all.
>
> Dated? Much of the S2 Ajax documentation is for S2.1, which isn't even
> released yet. If anything, it's pre-dated.
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
>
>
> ----Notice Regarding Confidentiality----
> This email, including any and all attachments, (this "Email") is
intended only for the party to whom it is addressed and may contain
information that is confidential or privileged. Sierra Systems Group
Inc. and its affiliates accept no responsibility for any loss or damage
suffered by any person resulting from any unauthorized use of or
reliance upon this Email. If you are not the intended recipient, you
are hereby notified that any dissemination, copying or other use of this
Email is prohibited. Please notify us of the error in communication by
return email and destroy all copies of this Email. Thank you.
>
>
>
------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.516 / Virus Database: 269.19.18/1255 - Release Date:
1/02/2008 9:59 AM
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

Attachment:
user_182155.ezm (zipped)--- "Griffith, Michael *" <Michael.Griffith@(protected):
> Thanks for the comprehensive reply. Looking at the documentation and the
> example app, I am still not sure how to configure my action/response. I
> am using tiles 2.
As previously stated if you are writing directly to the response you need to
return null from the action. I am still not sure why you're using a tile
definition here.
> It seems I need to return my result in JSON format correct? By returning
> a JSON String from the action, how to I configure my response?
As Jeremy said this is, however, probably a bad idea, considering that the
same outcome can be achieved in several different ways.
Using a JSON result will serialize your action to JSON automagically. You'd
use a "json" result (via the JSON plugin), not a tile. Or you could build the
JSON manually and configure a FreeMarker result.
> If I use the tiles response type, I get a dojo parsing error because the
> whole page is returned from the reply.
Sure.
> The example in the example app isn't very clear to me, as the action
> returns a .JS file with the result hard coded, and not using any
> template like tiles I might add.
What example are you referring to?
http://struts.apache.org/2.0.11/docs/ajax-tags.html#AjaxTags-autocompleterTag?
When making an Ajax request for a component like <s:autocompleter.../> it's
unlikely you'd want to return anything other than JSON. (Other components or
component libraries may want other formats like XML or whatever.) Unless your
tile definition is creating JSON it's not going to work, and it's unlikely
that would be the best way to generate the JSON anyway.
> Also, I think I found a bug? -- the namespace attribute seems to be
> ignored when I pass href=%{search} to the autocompleter. I had to put
> qualify the namespace in the value to get the correct action to be
> invoked.
When you configure the package does your namespace have a leading "/" (slash)
character? If it doesn't this can lead to dispatching issues.
Dave

Attachment:
user_182156.ezm (zipped)I completely agree with Dave so I'll take a different tact.
Based on this example:
http://struts.apache.org/2.0.11/docs/ajax-tags.html#AjaxTags-autocompleterTag,
I would also take the approach of returning a JSON Result via the JSON
Plugin. Only the configuration changes for an XML result.
So, my form looks like this:
<s:url id="json" value="/JSONList.action" />
<s:autocompleter theme="ajax" href="%{json}" dropdownHeight="180"/>
So, my struts.xml contains the corresponding action definition with a
JSON result:
<package name="example" extends="json-default">
<action name="JSONList" class="package.ListAction">
<result name="success" type="json">
<param name="root">list</param>
</result>
</action>
</package>
And my action method looks like this:
private ACEntry[] list;
public String execute() {
list = populateList()
return "success";
}
public ACEntry[] getList() {
return list;
}
---
In summary, the autocompleter does a get to /JSONList.action
Struts2 executes the execute method of ListAction
The execute method creates a structure that will populate the autocompleter
The action returns a JSON result type
The JSON plugin converts the root object (the list property only rather
than the whole action) to a JSON structure
The JSON plugin returns the application/json content to the autocompleter
I'll leave it to you to determine what the list structure should like
like. As it'll probably be re-use I'd create a bean for the purpose.
Use the FireBug plugin for firefox to inspect the format of the JSON
result to ensure it matches the format required by the javascript
library (or even better, write a unit test).
This will work with any javascript library that accepts JSON - you just
have to provide an appropriate structure. It will also work with any
library that requires an XML response, except you'd use an XML result
type like I previously described in this thread.
I hope that helps. Struts2 is really well suited at providing non-html
responses if you take the time to understand the ResultType architecture.
cheers,
Jeromy Evans
Dave Newton wrote:
> --- "Griffith, Michael *" <Michael.Griffith@(protected):
>
>> Thanks for the comprehensive reply. Looking at the documentation and the
>> example app, I am still not sure how to configure my action/response. I
>> am using tiles 2.
>>
>
> As previously stated if you are writing directly to the response you need to
> return null from the action. I am still not sure why you're using a tile
> definition here.
>
>
>
>> It seems I need to return my result in JSON format correct? By returning
>> a JSON String from the action, how to I configure my response?
>>
>
> As Jeremy said this is, however, probably a bad idea, considering that the
> same outcome can be achieved in several different ways.
>
> Using a JSON result will serialize your action to JSON automagically. You'd
> use a "json" result (via the JSON plugin), not a tile. Or you could build the
> JSON manually and configure a FreeMarker result.
>
>
>> If I use the tiles response type, I get a dojo parsing error because the
>> whole page is returned from the reply.
>>
>
> Sure.
>
>
>> The example in the example app isn't very clear to me, as the action
>> returns a .JS file with the result hard coded, and not using any
>> template like tiles I might add.
>>
>
> What example are you referring to?
>
> http://struts.apache.org/2.0.11/docs/ajax-tags.html#AjaxTags-autocompleterTag?
>
> When making an Ajax request for a component like <s:autocompleter.../> it's
> unlikely you'd want to return anything other than JSON. (Other components or
> component libraries may want other formats like XML or whatever.) Unless your
> tile definition is creating JSON it's not going to work, and it's unlikely
> that would be the best way to generate the JSON anyway.
>
>
>> Also, I think I found a bug? -- the namespace attribute seems to be
>> ignored when I pass href=%{search} to the autocompleter. I had to put
>> qualify the namespace in the value to get the correct action to be
>> invoked.
>>
>
> When you configure the package does your namespace have a leading "/" (slash)
> character? If it doesn't this can lead to dispatching issues.
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>
>
>
>