Re: [s1,validation] Multi-page flow, session-scoped DynaValidatorForm with checkbox

2011-06-17 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Dave,

Thanks for the quick reply.

On 6/17/2011 3:46 PM, Dave Newton wrote:
> On Friday, June 17, 2011, Christopher Schultz wrote:
>> I can't believe I've been working with Struts for nearly 10 years and
>> I'm still using Struts 1.
> 
> Fixed.

Yeah, really.

>> The problem is that if we check the box and submit to A2 (then show P2),
>> then go back (either browser-BACK or using our "previous" button in the
>> flow), then re-submit to A2, the form property in the bean stays set to
>> "true" (or whatever value we'r [...]
> 
> Not sure why it wouldn't, it's a session form, so alterations will
> persist over multiple pages, unless I'm misunderstanding what you've
> said.

My reading of the code is that with reset="true", the property will be
blanked-out on every request. Our solution (which seems to be working,
so at this point, this is just an academic discussion) was to do the
following:

1. Use reset="POST" -- we have a lot of GET-follows-POST semantics
2. Make sure the form element is included on every page of the flow

Now, #2 wasn't tough to do because all of our multi-page flows are coded
this way no matter what the scope of the form bean: we want to be able
to recover from a session-timeout without losing all the work the user
has put into filling it out.

So, basically, we just had to do #1 above and we were good to go.

Is that recommended technique in these cases where checkboxes need to be
reset?

>> I would have figured that DynaValidatorBean would be sensitive to the
>> current "page" of the flow and only reset properties with a page number
>> at or higher than the currently-being-submitted page
> 
> I'm not aware of any page number/flow functionality in S1, but I
> stopped using it around 1.2.9--is flow functionality something from
> 1.3, or did I just miss it altogether?

The validation framework understands the "page number" in order to
perform up-to-page-N validation, but I'm not sure the form itself has
any notion of the page numbering. Since DynaValidatorForm is tied-into
the validation framework, I wasn't sure if there were any super-smarts
there or not. Lots of classes, lots of code ;)

>> What is the recommended technique when dealing with multi-page,
>> session-scoped dynamic forms?
> 
> IIRC this was a PITA in S1, I always coded reset methods and had a
> mini-state-machine implementation.

Yeah, it really is a PITA. My review of an S2 book a while back got me
all excited about all the really great stuff in S2: IMO, it's the way
things should have been all along -- but nobody knew any better at the
time. Too bad "upgrade to a largely incompatible library" isn't a real
driving requirement for a product. :(

Thanks,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk37s3AACgkQ9CaO5/Lv0PCyaQCgpBg+yz75uW0XdkS13brdccGL
3HgAoL+rP4278HbhQ0qbKD+UaEX8KMWQ
=wSq9
-END PGP SIGNATURE-

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



Re: [s1,validation] Multi-page flow, session-scoped DynaValidatorForm with checkbox

2011-06-17 Thread Dave Newton
On Friday, June 17, 2011, Christopher Schultz wrote:
> I can't believe I've been working with Struts for nearly 10 years and
> I'm still using Struts 1.

Fixed.

> The problem is that if we check the box and submit to A2 (then show P2),
> then go back (either browser-BACK or using our "previous" button in the
> flow), then re-submit to A2, the form property in the bean stays set to
> "true" (or whatever value we'r [...]

Not sure why it wouldn't, it's a session form, so alterations will
persist over multiple pages, unless I'm misunderstanding what you've
said.

> I would have figured that DynaValidatorBean would be sensitive to the
> current "page" of the flow and only reset properties with a page number
> at or higher than the currently-being-submitted page

I'm not aware of any page number/flow functionality in S1, but I
stopped using it around 1.2.9--is flow functionality something from
1.3, or did I just miss it altogether?

> What is the recommended technique when dealing with multi-page,
> session-scoped dynamic forms?

IIRC this was a PITA in S1, I always coded reset methods and had a
mini-state-machine implementation.

Dave

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



[s1,validation] Multi-page flow, session-scoped DynaValidatorForm with checkbox

2011-06-17 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

All,

I can't believe I've been working with Struts for nearly 10 years and
I'm only now attempting to use a multi-page flow with a form bean in the
session.

Of course, I'm having difficulty with checkboxes.

Our (simplified) flow looks something like this:

P1 -> A1 ---> P2 -> A2 ---> Done

"P1" contains a checkbox called "emailNotification". The bean is defined
with a 

The "Done" page would like to use the value of that form property to
decide (you guessed it) whether or not to notify someone via email.

The problem is that if we check the box and submit to A2 (then show P2),
then go back (either browser-BACK or using our "previous" button in the
flow), then re-submit to A2, the form property in the bean stays set to
"true" (or whatever value we're using).

I've been looking at the "reset" attribute of the 
element in struts-config.xml and, at first glance, it looks promising.

Reading the code, however, it looks like setting reset="true" will end
up re-setting the form property to null (or blank string) upon every
request, meaning that my multi-page flow will have to repeat that form
element on every page.

I would have figured that DynaValidatorBean would be sensitive to the
current "page" of the flow and only reset properties with a page number
at or higher than the currently-being-submitted page (if you ignore the
chicken-in-the-egg problem of inspecting the request before resetting
the form before ... inspecting the request).

Is my analysis above correct?

What is the recommended technique when dealing with multi-page,
session-scoped dynamic forms?

Thanks,
- -chris
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk37rAIACgkQ9CaO5/Lv0PALZgCfbeXZ8UD/IAPB+trVyUUUFp3u
aBsAoJBcDSGvaTP9i5KVh5XUOOVCkbk0
=boCA
-END PGP SIGNATURE-

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



@RequiredStringValidator annotation key

2011-06-17 Thread struts2query
Hi,
I would like to know how to pass parameter to a message stored in resource
bundle in @RequiredStringValidator annotation 

Example

@RequiredStringValidator(key="userkey")
  
public String getUsername() {

 return username;
  }


and in resource bundle it is like something
userkey = {0} {1} some message

problem here is that @RequiredStringValidator takes only "key" that lookup
in resorce bundle, but there is no provision to make key with some
placeholder like {0}

Please reply if anyone came across this scenario.

Thanks. 

--
View this message in context: 
http://struts.1045723.n5.nabble.com/RequiredStringValidator-annotation-key-tp4499592p4499592.html
Sent from the Struts - User mailing list archive at Nabble.com.

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



Re: Problem with configured action method names and Testing Framework - Action Testing with configured method names is broken in struts-2.2.3

2011-06-17 Thread UV

Of course I configured a method with the same name and returning String?!?

But this is about using the action test framework of struts on actions 
configured with a method name

in the XML instead of using the default execute()
(which I  use as a workaround now)

So changing the names I use in the xml configuration should have nothing 
to do with it, as the reflection code only seems to be able to find the 
execute() method which is part of the action interface.


I have been deep in this with the debugger and I am actually pretty sure 
by now
that this is a defect in the testing framework which has not been 
addressed yet.


So for now: Action Testing with configured method names is NOT WORKING 
in struts-2.2.3


On 17/06/2011 07:24, Lukasz Lenart wrote:

2011/6/17 UV:

When I try to test an action with a method="actionMethod" attribute
configured in a  StrutsTestCase
the AnnotationValidationInterceptor fails in getActionMethod#75 cause it
cannot find the method

Try to name your method actionMethod instead of getActionMethod and of
return type String


Regards



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



Re: getText on XSLT transformation on an Action

2011-06-17 Thread JOSE L MARTINEZ-AVIAL
humm, that could do the trick. Altough I would need to extend it to get the
locale from the ActionContext.

2011/6/17 Maurizio Cucchiara 

> is that [1] what you are looking for?
>
> [1] http://www.javaworld.com/javaworld/jw-12-2001/jw-1221-xslt.html?page=3
>
> On 17 June 2011 09:26,  wrote:
> >
> > Well, the XML comes from an external provider through a webservice, so I
> would prefer otheer solution...if possible.
> > Sent via BlackBerry from T-Mobile
> >
> > -Original Message-
> > From: Chris Pratt 
> > Date: Thu, 16 Jun 2011 22:24:33
> > To: Struts Users Mailing List
> > Reply-To: "Struts Users Mailing List" 
> > Subject: Re: getText on XSLT transformation on an Action
> >
> > There's no reason the XSL should be dynamic.  The XML is typically the
> > dynamic part with the XSL being static (so that it can be parsed and
> cached
> > for efficiency).  Why not include a section in the XML with the
> replacement
> > text, then reference the strings using XPath?
> >  (*Chris*)
> >
> > On Thu, Jun 16, 2011 at 5:34 PM, Miguel  wrote:
> >
> > > Yes, if you want this, you need to create the XSLT on the fly,
> > > You can use freemarker to achieve this. substituying the placeholders
> > > with the appropiate text.
> > > You can use even apache commons StringUtils if you only want to
> > > susbtitute placeholders with fixed text.
> > >
> > > Cheers,
> > >
> > > Si quieres ser más positivo, pierde un electrón
> > > Miguel Ruiz Velasco Sobrino
> > >
> > >
> > >
> > > On Thu, Jun 16, 2011 at 19:31, JOSE L MARTINEZ-AVIAL  >
> > > wrote:
> > > > could you expand that? do you mean to create the XSLT on the fly?
> > > >
> > > > 2011/6/16 Maurizio Cucchiara 
> > > >
> > > >> The first solution I thought is: a template engine.
> > > >> Currently your xslt file is static, you should consider to make
> dynamic
> > > in
> > > >> order to include dynamic content.
> > > >>
> > > >> Maurizio Cucchiara
> > > >>
> > > >> Il giorno 16/giu/2011 19.37, "JOSE L MARTINEZ-AVIAL" <
> jlm...@gmail.com>
> > > ha
> > > >> scritto:
> > > >> > Hi,
> > > >> > I'm using Struts 2.1.8.1. I have an action that retrieves some XML
> > > data
> > > >> > from a webservice, and transform it to HTML using XSLT. The
> > > >> transformation
> > > >> > is done in the action, and the output is returned as a stream and
> sent
> > > to
> > > >> > the client. It works fine, but now I need to write some labels
> that
> > > >> depend
> > > >> > on the user's locale. Is there any way to call getText from the
> XSLT
> > > >> > stylesheet, so it uses the action that called the transformer as
> the
> > > >> basis
> > > >> > to look for the package with the labels in the diferent languages?
> It
> > > >> should
> > > >> > also use the user's locale, but since it gets it from the
> > > ActionContext,
> > > >> it
> > > >> > should work fine.
> > > >> >
> > > >> > Thanks
> > > >> >
> > > >> > Jose
> > > >>
> > > >
> > >
> > > -
> > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > > For additional commands, e-mail: user-h...@struts.apache.org
> > >
> > >
> >
>
>
>
> --
> Maurizio Cucchiara
>


Re: getText on XSLT transformation on an Action

2011-06-17 Thread Chris Pratt
Just remember that one of the more expensive parts of using XSLT is
compiling the XSL StyleSheet. So using a dynamic StyleSheet will come with a
cost.  Another option would be to extend the XslResult to somehow provide
dynamic data during the translation.  Possibly as an XSL Extension, or at
least using the setParameter mechanism.
  (*Chris*)
On Jun 17, 2011 12:27 AM,  wrote:
> Well, the XML comes from an external provider through a webservice, so I
would prefer otheer solution...if possible.
> Sent via BlackBerry from T-Mobile
>
> -Original Message-
> From: Chris Pratt 
> Date: Thu, 16 Jun 2011 22:24:33
> To: Struts Users Mailing List
> Reply-To: "Struts Users Mailing List" 
> Subject: Re: getText on XSLT transformation on an Action
>
> There's no reason the XSL should be dynamic. The XML is typically the
> dynamic part with the XSL being static (so that it can be parsed and
cached
> for efficiency). Why not include a section in the XML with the replacement
> text, then reference the strings using XPath?
> (*Chris*)
>
> On Thu, Jun 16, 2011 at 5:34 PM, Miguel  wrote:
>
>> Yes, if you want this, you need to create the XSLT on the fly,
>> You can use freemarker to achieve this. substituying the placeholders
>> with the appropiate text.
>> You can use even apache commons StringUtils if you only want to
>> susbtitute placeholders with fixed text.
>>
>> Cheers,
>>
>> Si quieres ser más positivo, pierde un electrón
>> Miguel Ruiz Velasco Sobrino
>>
>>
>>
>> On Thu, Jun 16, 2011 at 19:31, JOSE L MARTINEZ-AVIAL 
>> wrote:
>> > could you expand that? do you mean to create the XSLT on the fly?
>> >
>> > 2011/6/16 Maurizio Cucchiara 
>> >
>> >> The first solution I thought is: a template engine.
>> >> Currently your xslt file is static, you should consider to make
dynamic
>> in
>> >> order to include dynamic content.
>> >>
>> >> Maurizio Cucchiara
>> >>
>> >> Il giorno 16/giu/2011 19.37, "JOSE L MARTINEZ-AVIAL" 
>> ha
>> >> scritto:
>> >> > Hi,
>> >> > I'm using Struts 2.1.8.1. I have an action that retrieves some XML
>> data
>> >> > from a webservice, and transform it to HTML using XSLT. The
>> >> transformation
>> >> > is done in the action, and the output is returned as a stream and
sent
>> to
>> >> > the client. It works fine, but now I need to write some labels that
>> >> depend
>> >> > on the user's locale. Is there any way to call getText from the XSLT
>> >> > stylesheet, so it uses the action that called the transformer as the
>> >> basis
>> >> > to look for the package with the labels in the diferent languages?
It
>> >> should
>> >> > also use the user's locale, but since it gets it from the
>> ActionContext,
>> >> it
>> >> > should work fine.
>> >> >
>> >> > Thanks
>> >> >
>> >> > Jose
>> >>
>> >
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
>


Re: getText on XSLT transformation on an Action

2011-06-17 Thread Maurizio Cucchiara
is that [1] what you are looking for?

[1] http://www.javaworld.com/javaworld/jw-12-2001/jw-1221-xslt.html?page=3

On 17 June 2011 09:26,  wrote:
>
> Well, the XML comes from an external provider through a webservice, so I 
> would prefer otheer solution...if possible.
> Sent via BlackBerry from T-Mobile
>
> -Original Message-
> From: Chris Pratt 
> Date: Thu, 16 Jun 2011 22:24:33
> To: Struts Users Mailing List
> Reply-To: "Struts Users Mailing List" 
> Subject: Re: getText on XSLT transformation on an Action
>
> There's no reason the XSL should be dynamic.  The XML is typically the
> dynamic part with the XSL being static (so that it can be parsed and cached
> for efficiency).  Why not include a section in the XML with the replacement
> text, then reference the strings using XPath?
>  (*Chris*)
>
> On Thu, Jun 16, 2011 at 5:34 PM, Miguel  wrote:
>
> > Yes, if you want this, you need to create the XSLT on the fly,
> > You can use freemarker to achieve this. substituying the placeholders
> > with the appropiate text.
> > You can use even apache commons StringUtils if you only want to
> > susbtitute placeholders with fixed text.
> >
> > Cheers,
> >
> > Si quieres ser más positivo, pierde un electrón
> > Miguel Ruiz Velasco Sobrino
> >
> >
> >
> > On Thu, Jun 16, 2011 at 19:31, JOSE L MARTINEZ-AVIAL 
> > wrote:
> > > could you expand that? do you mean to create the XSLT on the fly?
> > >
> > > 2011/6/16 Maurizio Cucchiara 
> > >
> > >> The first solution I thought is: a template engine.
> > >> Currently your xslt file is static, you should consider to make dynamic
> > in
> > >> order to include dynamic content.
> > >>
> > >> Maurizio Cucchiara
> > >>
> > >> Il giorno 16/giu/2011 19.37, "JOSE L MARTINEZ-AVIAL" 
> > ha
> > >> scritto:
> > >> > Hi,
> > >> > I'm using Struts 2.1.8.1. I have an action that retrieves some XML
> > data
> > >> > from a webservice, and transform it to HTML using XSLT. The
> > >> transformation
> > >> > is done in the action, and the output is returned as a stream and sent
> > to
> > >> > the client. It works fine, but now I need to write some labels that
> > >> depend
> > >> > on the user's locale. Is there any way to call getText from the XSLT
> > >> > stylesheet, so it uses the action that called the transformer as the
> > >> basis
> > >> > to look for the package with the labels in the diferent languages? It
> > >> should
> > >> > also use the user's locale, but since it gets it from the
> > ActionContext,
> > >> it
> > >> > should work fine.
> > >> >
> > >> > Thanks
> > >> >
> > >> > Jose
> > >>
> > >
> >
> > -
> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> > For additional commands, e-mail: user-h...@struts.apache.org
> >
> >
>



--
Maurizio Cucchiara

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



Re: getText on XSLT transformation on an Action

2011-06-17 Thread jlmagc
Well, the XML comes from an external provider through a webservice, so I would 
prefer otheer solution...if possible.
Sent via BlackBerry from T-Mobile

-Original Message-
From: Chris Pratt 
Date: Thu, 16 Jun 2011 22:24:33 
To: Struts Users Mailing List
Reply-To: "Struts Users Mailing List" 
Subject: Re: getText on XSLT transformation on an Action

There's no reason the XSL should be dynamic.  The XML is typically the
dynamic part with the XSL being static (so that it can be parsed and cached
for efficiency).  Why not include a section in the XML with the replacement
text, then reference the strings using XPath?
  (*Chris*)

On Thu, Jun 16, 2011 at 5:34 PM, Miguel  wrote:

> Yes, if you want this, you need to create the XSLT on the fly,
> You can use freemarker to achieve this. substituying the placeholders
> with the appropiate text.
> You can use even apache commons StringUtils if you only want to
> susbtitute placeholders with fixed text.
>
> Cheers,
>
> Si quieres ser más positivo, pierde un electrón
> Miguel Ruiz Velasco Sobrino
>
>
>
> On Thu, Jun 16, 2011 at 19:31, JOSE L MARTINEZ-AVIAL 
> wrote:
> > could you expand that? do you mean to create the XSLT on the fly?
> >
> > 2011/6/16 Maurizio Cucchiara 
> >
> >> The first solution I thought is: a template engine.
> >> Currently your xslt file is static, you should consider to make dynamic
> in
> >> order to include dynamic content.
> >>
> >> Maurizio Cucchiara
> >>
> >> Il giorno 16/giu/2011 19.37, "JOSE L MARTINEZ-AVIAL" 
> ha
> >> scritto:
> >> > Hi,
> >> > I'm using Struts 2.1.8.1. I have an action that retrieves some XML
> data
> >> > from a webservice, and transform it to HTML using XSLT. The
> >> transformation
> >> > is done in the action, and the output is returned as a stream and sent
> to
> >> > the client. It works fine, but now I need to write some labels that
> >> depend
> >> > on the user's locale. Is there any way to call getText from the XSLT
> >> > stylesheet, so it uses the action that called the transformer as the
> >> basis
> >> > to look for the package with the labels in the diferent languages? It
> >> should
> >> > also use the user's locale, but since it gets it from the
> ActionContext,
> >> it
> >> > should work fine.
> >> >
> >> > Thanks
> >> >
> >> > Jose
> >>
> >
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>