Struts2 s:form to html form changes id attribute

2010-12-16 Thread webmeiker
Hi,

Does somebody know what could be happening here?



I have exactly same Struts2 web app deployed in two Tomcats but  tag
behaves strange in one of them.



Lets explain myself…



The next line of code in my JSP:







…generates correct html form code in ‘A’ environment:







…BUT generates wrong html markup in ‘B’ environment, in concrete value of
‘id’ attribute should be ‘anunciosListar’:







Why ‘id’ and ‘name’ attributes where interchanged in form markup of scenario
‘B’?


Thanks!!

--


Re: Parameter manipulation

2010-12-16 Thread Steven Yang
is your user object initialized when the param interceptor is run?

here i might be wrong, but what i know is if your object is initialized then
Struts or OGNL will call getUser().setEmail(...)
otherwise create a new User then setEmail then setUser
then the second case should fail for you

again, i might be wrong on the behavior

On Thu, Dec 16, 2010 at 12:39 AM, Altenhof, David Aron
wrote:

> I've been getting more and more concerned about the possibility of
> parameter manipulation attacks with Struts2. I've started doing strict
> whitelists using the ParameterNameAware interface on all of my forms pages.
> However, today I tried to code a "display-only" page that shows information
> about a particular user. I thought that by simply creating a getter and no
> setter, it would be impossible to inject parameters. For example, my action
> only contains the following getter for a JPA model object:
>
> public User getUser() {
>return user;
> }
>
> However, by sending a simple query parameter, it is *still* possible to
> change values in user. For example, you can send:
>
>
> http://localhost:8080/MySite/userdisplay.action?user.email=newem...@address.com
>
> ... and it works. The email will become newem...@address.com
>
> Is there any way to shut this down other than whitelisting every single
> action in your site using ParameterNameAware? (Or simply never put model
> objects on your stack?) This is getting frustrating!
>
> -David
>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


Re: Struts2 IDE, eclipse plugins to manage struts2 xml file, areyou interested?

2010-12-16 Thread Hantsy Bai

于 2010/12/17 10:17, Frans Thamura 写道:
> Right
>
> Is the source available also? 
> /m/
>
> -Original Message-
> From: Johannes Geppert 
> Date: Thu, 16 Dec 2010 11:35:50 
> To: 
> Reply-To: "Struts Users Mailing List" 
> Subject: Re: Struts2 IDE, eclipse plugins to manage struts2 xml file, are
>  you interested?
>
>
> Hi Angelo,
>
> this looks great. When do you think is this available?
> Is there a Beta version available for tests?
>
> Best Regards
>
> Johannes Geppert
>
>
> azerr wrote:
>> Hi Struts2 Team,
>>
>> I introduce to me. I'm Angelo ZERR and I'm developping a generic XML
>> search
>> engine Eclipse plugins that I would like contribute to WTP Eclipse (please
>> read bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=330576).
>> This plugins give you the capability to :
>>
>> * search XML nodes with XPath from your workspace files.
>> * develop your plugins to manage compeltion, validation, hyperlink for
>> custom XML files.
>>
>> I have started to create plugins for Jetty and I have started to develop
>> Struts2 IDE based on XML Search engine to manage struts2.xml (I have
>> developped Struts2 IDE in 2 hours).
>>
>> On other words you benefit :
>>
>> * Java completion, validation, hyperlink for @class attribute in your
>> struts.xml
>> * XML completion, validation, hyperlink (ex : having completion for
>> interceptor, interceptor-stack for interceptor-ref)
>>
>> You can see screenshot in (ODT) documentation that I have attached. If you
>> can not read ODT, I have commited a RTF version at
>> https://tk-ui.svn.sourceforge.net/svnroot/tk-ui/cnaf.sidoc.ide/docs I have
>> stared Struts2 IDE to validate my XML Search engine, but I have another
>> thing to manage (like Java method).
>> If you are interested with Struts2 IDE, tell me and I will continue to
>> improve it.
>>
>> Regards Angelo
>>
>>  
>>
>> -
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>
> -
> ---
> web: http://www.jgeppert.com
> twitter: http://twitter.com/jogep
>
Great news for Struts2 developers.
As far as I know, there is no good open source Struts2 plugin for Eclipse.
MyEclipse provides such one, but it is an commercial product, you need a
subscription.

NetBeans has a good plugin for Struts2 development,
http://nbstruts2support.dev.java.net.

Kind regards
Hantsy

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



Re: Struts2 IDE, eclipse plugins to manage struts2 xml file, areyou interested?

2010-12-16 Thread Frans Thamura
Right

Is the source available also? 
/m/

-Original Message-
From: Johannes Geppert 
Date: Thu, 16 Dec 2010 11:35:50 
To: 
Reply-To: "Struts Users Mailing List" 
Subject: Re: Struts2 IDE, eclipse plugins to manage struts2 xml file, are
 you interested?


Hi Angelo,

this looks great. When do you think is this available?
Is there a Beta version available for tests?

Best Regards

Johannes Geppert


azerr wrote:
> 
> Hi Struts2 Team,
> 
> I introduce to me. I'm Angelo ZERR and I'm developping a generic XML
> search
> engine Eclipse plugins that I would like contribute to WTP Eclipse (please
> read bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=330576).
> This plugins give you the capability to :
> 
> * search XML nodes with XPath from your workspace files.
> * develop your plugins to manage compeltion, validation, hyperlink for
> custom XML files.
> 
> I have started to create plugins for Jetty and I have started to develop
> Struts2 IDE based on XML Search engine to manage struts2.xml (I have
> developped Struts2 IDE in 2 hours).
> 
> On other words you benefit :
> 
> * Java completion, validation, hyperlink for @class attribute in your
> struts.xml
> * XML completion, validation, hyperlink (ex : having completion for
> interceptor, interceptor-stack for interceptor-ref)
> 
> You can see screenshot in (ODT) documentation that I have attached. If you
> can not read ODT, I have commited a RTF version at
> https://tk-ui.svn.sourceforge.net/svnroot/tk-ui/cnaf.sidoc.ide/docs I have
> stared Struts2 IDE to validate my XML Search engine, but I have another
> thing to manage (like Java method).
> If you are interested with Struts2 IDE, tell me and I will continue to
> improve it.
> 
> Regards Angelo
> 
>  
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 


-
---
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep

-- 
View this message in context: 
http://old.nabble.com/Struts2-IDE%2C-eclipse-plugins-to-manage-struts2-xml-file%2C-are-you-interested--tp30471440p30475686.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 action mapping

2010-12-16 Thread Dave Newton
Older Struts/Tiles was notorious (at least in my experience) for swallowing
exceptions whole. My first guess is that something is broken in one of your
JSPs used by the tile.

That's one good reason not to use such old technology for new development:
you lose the benefits of hundreds of thousands of man-hours of experience
generally used to create better, more robust platforms.

Dave

On Thu, Dec 16, 2010 at 3:27 PM, Anjib Mulepati  wrote:

> There was space at the beginning. That is solved. I'm getting something but
> not whole page just logo and header.
> I though name should be body in tiles def file. so I change all to bosy as
> tiles.jsp has attribute="body"
>
> Still same problem.
>
>
> Anjib
>
> On 12/16/2010 2:15 PM, Dave Newton wrote:
>
>> A startup error. Check the logs.
>>
>> Dave
>>
>> On Thu, Dec 16, 2010 at 1:59 PM, Anjib Mulepati
>>  wrote:
>>
>>  This is the problem I am facing everytime I am creating new project in
>>> Netbeans and modify the default pages. Am I missing some sequence of
>>> action
>>> or parameters. To make it clear I am including most of the code which I
>>> think are related. Can any one suggets me why I am getting following
>>> error
>>> when I run my application.
>>>
>>> *type* Status report
>>>
>>> *message* _Servlet action is currently unavailable_
>>>
>>> *description* _The requested service (Servlet action is currently
>>> unavailable) is not currently available.
>>> _
>>>
>>> _
>>> _Code fragments_
>>> _
>>>
>>> 1. Tiles layout jsp page (tiles.jsp)
>>> -
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 2. I have struts tiles as
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>>> 3. My struts-config files as
>>> -
>>> 
>>> 
>>>
>>> >>scope="request"
>>> type="gov.ma.itd.grouping.actions.LoginAction">
>>> 
>>> 
>>> 
>>> 
>>>
>>> 4. My web.xml files as
>>> ---
>>> 
>>> action
>>> *.do
>>> 
>>> 
>>> 
>>>30
>>> 
>>> 
>>> 
>>> index.jsp
>>> 
>>>
>>> 5. index.jsp
>>> 
>>> 
>>>
>>> 6. And ofcourse I have login.jsp,  groupIn.jsp, header.jsp, and
>>> footer.jsp
>>> pages.
>>>
>>> Thanks
>>> Anjib
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


Re: Problem with action mapping

2010-12-16 Thread Anjib Mulepati
There was space at the beginning. That is solved. I'm getting something 
but not whole page just logo and header.
I though name should be body in tiles def file. so I change all to bosy 
as tiles.jsp has attribute="body"


Still same problem.

Anjib

On 12/16/2010 2:15 PM, Dave Newton wrote:

A startup error. Check the logs.

Dave

On Thu, Dec 16, 2010 at 1:59 PM, Anjib Mulepati  wrote:


This is the problem I am facing everytime I am creating new project in
Netbeans and modify the default pages. Am I missing some sequence of action
or parameters. To make it clear I am including most of the code which I
think are related. Can any one suggets me why I am getting following error
when I run my application.

*type* Status report

*message* _Servlet action is currently unavailable_

*description* _The requested service (Servlet action is currently
unavailable) is not currently available.
_

_
_Code fragments_
_

1. Tiles layout jsp page (tiles.jsp)
-


















2. I have struts tiles as


















3. My struts-config files as
-









4. My web.xml files as
---

action
*.do



30



index.jsp


5. index.jsp



6. And ofcourse I have login.jsp,  groupIn.jsp, header.jsp, and footer.jsp
pages.

Thanks
Anjib










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



Re: Struts2 IDE, eclipse plugins to manage struts2 xml file, are you interested?

2010-12-16 Thread Johannes Geppert

Hi Angelo,

this looks great. When do you think is this available?
Is there a Beta version available for tests?

Best Regards

Johannes Geppert


azerr wrote:
> 
> Hi Struts2 Team,
> 
> I introduce to me. I'm Angelo ZERR and I'm developping a generic XML
> search
> engine Eclipse plugins that I would like contribute to WTP Eclipse (please
> read bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=330576).
> This plugins give you the capability to :
> 
> * search XML nodes with XPath from your workspace files.
> * develop your plugins to manage compeltion, validation, hyperlink for
> custom XML files.
> 
> I have started to create plugins for Jetty and I have started to develop
> Struts2 IDE based on XML Search engine to manage struts2.xml (I have
> developped Struts2 IDE in 2 hours).
> 
> On other words you benefit :
> 
> * Java completion, validation, hyperlink for @class attribute in your
> struts.xml
> * XML completion, validation, hyperlink (ex : having completion for
> interceptor, interceptor-stack for interceptor-ref)
> 
> You can see screenshot in (ODT) documentation that I have attached. If you
> can not read ODT, I have commited a RTF version at
> https://tk-ui.svn.sourceforge.net/svnroot/tk-ui/cnaf.sidoc.ide/docs I have
> stared Struts2 IDE to validate my XML Search engine, but I have another
> thing to manage (like Java method).
> If you are interested with Struts2 IDE, tell me and I will continue to
> improve it.
> 
> Regards Angelo
> 
>  
> 
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 


-
---
web: http://www.jgeppert.com
twitter: http://twitter.com/jogep

-- 
View this message in context: 
http://old.nabble.com/Struts2-IDE%2C-eclipse-plugins-to-manage-struts2-xml-file%2C-are-you-interested--tp30471440p30475686.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 action mapping

2010-12-16 Thread Dave Newton
You'll probably want to turn your logging up to DEBUG.

Dave

On Thu, Dec 16, 2010 at 2:27 PM, Anjib Mulepati  wrote:

> Tomcat Log in Netbeans says
>
> Dec 16, 2010 2:26:03 PM org.apache.catalina.core.ApplicationDispatcher
> invoke
> WARNING: Servlet action is currently unavailable
>
> Anjib
>
>
>
> On 12/16/2010 2:15 PM, Dave Newton wrote:
>
>> A startup error. Check the logs.
>>
>> Dave
>>
>> On Thu, Dec 16, 2010 at 1:59 PM, Anjib Mulepati
>>  wrote:
>>
>>  This is the problem I am facing everytime I am creating new project in
>>> Netbeans and modify the default pages. Am I missing some sequence of
>>> action
>>> or parameters. To make it clear I am including most of the code which I
>>> think are related. Can any one suggets me why I am getting following
>>> error
>>> when I run my application.
>>>
>>> *type* Status report
>>>
>>> *message* _Servlet action is currently unavailable_
>>>
>>> *description* _The requested service (Servlet action is currently
>>> unavailable) is not currently available.
>>> _
>>>
>>> _
>>> _Code fragments_
>>> _
>>>
>>> 1. Tiles layout jsp page (tiles.jsp)
>>> -
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 2. I have struts tiles as
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>>> 
>>> 
>>> 
>>> 
>>>
>>> 3. My struts-config files as
>>> -
>>> 
>>> 
>>>
>>> >>scope="request"
>>> type="gov.ma.itd.grouping.actions.LoginAction">
>>> 
>>> 
>>> 
>>> 
>>>
>>> 4. My web.xml files as
>>> ---
>>> 
>>> action
>>> *.do
>>> 
>>> 
>>> 
>>>30
>>> 
>>> 
>>> 
>>> index.jsp
>>> 
>>>
>>> 5. index.jsp
>>> 
>>> 
>>>
>>> 6. And ofcourse I have login.jsp,  groupIn.jsp, header.jsp, and
>>> footer.jsp
>>> pages.
>>>
>>> Thanks
>>> Anjib
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>


Re: Problem with action mapping

2010-12-16 Thread Anjib Mulepati

Tomcat Log in Netbeans says

Dec 16, 2010 2:26:03 PM org.apache.catalina.core.ApplicationDispatcher 
invoke

WARNING: Servlet action is currently unavailable

Anjib


On 12/16/2010 2:15 PM, Dave Newton wrote:

A startup error. Check the logs.

Dave

On Thu, Dec 16, 2010 at 1:59 PM, Anjib Mulepati  wrote:


This is the problem I am facing everytime I am creating new project in
Netbeans and modify the default pages. Am I missing some sequence of action
or parameters. To make it clear I am including most of the code which I
think are related. Can any one suggets me why I am getting following error
when I run my application.

*type* Status report

*message* _Servlet action is currently unavailable_

*description* _The requested service (Servlet action is currently
unavailable) is not currently available.
_

_
_Code fragments_
_

1. Tiles layout jsp page (tiles.jsp)
-


















2. I have struts tiles as


















3. My struts-config files as
-









4. My web.xml files as
---

action
*.do



30



index.jsp


5. index.jsp



6. And ofcourse I have login.jsp,  groupIn.jsp, header.jsp, and footer.jsp
pages.

Thanks
Anjib










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



Re: Problem with action mapping

2010-12-16 Thread Dave Newton
A startup error. Check the logs.

Dave

On Thu, Dec 16, 2010 at 1:59 PM, Anjib Mulepati  wrote:

> This is the problem I am facing everytime I am creating new project in
> Netbeans and modify the default pages. Am I missing some sequence of action
> or parameters. To make it clear I am including most of the code which I
> think are related. Can any one suggets me why I am getting following error
> when I run my application.
>
> *type* Status report
>
> *message* _Servlet action is currently unavailable_
>
> *description* _The requested service (Servlet action is currently
> unavailable) is not currently available.
> _
>
> _
> _Code fragments_
> _
>
> 1. Tiles layout jsp page (tiles.jsp)
> -
> 
> 
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> 2. I have struts tiles as
> 
> 
> 
> 
> 
> 
> 
>
> 
> 
> 
> 
>
> 
> 
> 
> 
>
> 3. My struts-config files as
> -
> 
> 
>
> scope="request"
> type="gov.ma.itd.grouping.actions.LoginAction" >
> 
> 
> 
> 
>
> 4. My web.xml files as
> ---
> 
> action
> *.do
> 
> 
> 
>30
> 
> 
> 
> index.jsp
> 
>
> 5. index.jsp
> 
> 
>
> 6. And ofcourse I have login.jsp,  groupIn.jsp, header.jsp, and footer.jsp
> pages.
>
> Thanks
> Anjib
>
>
>
>
>
>
>


Problem with action mapping

2010-12-16 Thread Anjib Mulepati
This is the problem I am facing everytime I am creating new project in 
Netbeans and modify the default pages. Am I missing some sequence of 
action or parameters. To make it clear I am including most of the code 
which I think are related. Can any one suggets me why I am getting 
following error when I run my application.


*type* Status report

*message* _Servlet action is currently unavailable_

*description* _The requested service (Servlet action is currently 
unavailable) is not currently available.

_

_
_Code fragments_
_

1. Tiles layout jsp page (tiles.jsp)
-



















2. I have struts tiles as


















3. My struts-config files as
-



scope="request" 
type="gov.ma.itd.grouping.actions.LoginAction" >






4. My web.xml files as
---

action
*.do



30



index.jsp


5. index.jsp



6. And ofcourse I have login.jsp,  groupIn.jsp, header.jsp, and 
footer.jsp pages.


Thanks
Anjib








Convention Plugin, Inheriting from existing projects action

2010-12-16 Thread Arne Stabenau
Hello,

We are developing here a fairly generic web tool, which for many of our projects
we just want to customize a little. We are using the convention
plugin, since I have
a little dislike of XML config files and want to keep them to a minimum.

Ideally I would like a way to just include the base project into my
classpath and when
I want to customize an action, just subclass it and implement either a
new method
for the action or overwrite some method in the original action to do
the customization.

Well, I tried this and sometimes the subclass is used as action,
sometimes the original,
and I can't really figure out why is that. I was expecting an error
message for re-using
the same action-name (actually a warning log entry).

-- from convention plugin ---

       //check if an action with the same name exists on that package
(from XML config probably)
700        PackageConfig existingPkg =
configuration.getPackageConfig(pkgCfg.getName());
701        if (existingPkg != null) {
702            // there is a package already with that name, check action
703            ActionConfig existingActionConfig =
existingPkg.getActionConfigs().get(actionName);
704            if (existingActionConfig != null && LOG.isWarnEnabled())
705                LOG.warn("Duplicated action definition in package
[#0] with name [#1].", pkgCfg.getName(), actionName);
706        }

Can it be done? With reasonable modification of the struts framework maybe?

Thanks for reading,

Arne

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



Re: Struts 2 Conditional Validators?

2010-12-16 Thread RogerV



Dave Newton-6 wrote:
> 
> Validators aren't called when *you* call a method, its not like they
> cause byte-code to be inserted.
> 
> Dave
> 

Ok - bad choice of words. Validation annotations are processed by the
AnnotationValidationInterceptor. How it decides what to process I find a bit
hazy. There is super class ValidationInterceptor call made
actionValidatorManager.validate(action, context, method); 
which I assumed meant that the interceptor was looking to process only those
annotations on the method being called, rather than looking for all the
annotations in the class and applying them in turn (which is what the
VistorValidator seems to do unfortunately). I kind lost it at this point as
Struts found and executed my annotations although they were on methods
called by execute() rather than being placed on execute() itself.

Regards

Regards
-- 
View this message in context: 
http://old.nabble.com/Struts-2-Conditional-Validators--tp30471468p30472121.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: unicode breaks s:select?

2010-12-16 Thread Alex Rodriguez Lopez

Have you got this on top of JSPs?

<%@ page contentType="text/html; charset=UTF-8" %>

Patrick Cosmo, 15-12-2010 17:40:

Hi!

When using "s:select", if the list of data returned by my java class contains strings 
that have unicode characters in them, "s:select" fails to generate the entire tag, it 
dies at the unicode character.

For example, this tag:



When "userTypeList" has as its first item the string "Actualización_GZ" the 
resulting page source is:


 mailto:pco...@incognito.com>
www.incognito.com






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



Re: Struts 2 Conditional Validators?

2010-12-16 Thread Dave Newton
Validators aren't called when *you* call a method, its not like they
cause byte-code to be inserted.

Dave

On Thursday, December 16, 2010, RogerV  wrote:
>
> Hi
>
> Is it possible to "conditionally" trigger a validator such that if
> conditionA then use ValidatorX else use ValidatorY within the validation
> framework out of the box?
>
> I have a scenario where a user is entering a serial number as a license key.
> They can either enter a full serial number which licenses a particular
> machine, or they can enter a "generic" license number, for example "DEF*"
> which licenses all machine of a particular model. These keys end up in the
> same column in the database and there is a single "serial Number field" in
> the data capture form and hence a single attribute in my action. And of
> course, they need validating differently.
>
> The obvious solution to create two seperate input fields on the .jsp form
> has been vetoed by the client. I have tried calling two seperate methods and
> attaching the validators to the individual methods like;
>
> public String execute() {
>                 if (licenseId.endsWith("*")) {
>                         addGenericLicense(licenseId);
>                 } else {
>                         addSpecificLicense(licenseId);
>                 }
>                         return SUCCESS;
>         }
>
>
>
> @CustomValidator(fieldName="licenseId",type="SpecificLicense",message="Invalid
> License key")
>
>         private void addSpecificLicense(String licenseId) {
>                 getNewUserDTO().addSpecificLicense(licenseId);
>
>         }
>
>
> @CustomValidator(fieldName="licenseId",type="GenericLicense",message="Invalid
> Generic License key")
>         private void addGenericLicense(String licenseId) {
>                         getNewUserDTO().addGenericLicense(licenseId);
>
>         }
>
> but that doesn't work either - it looks like when either method
> (addGenericLicense() or addSpecificLicense() is executed, all the validators
> for the field licenseId are called and both validators fire.
>
> I could of course, just write a validate() method in my action, but I would
> like to keep the validators as I can re-use them elsewhere, so if there's no
> way to have an "either/or validator" through the framework, I was wondering
> if there is way of "nesting" the validators. Something along the lines of
> having one single validator for the license key that programmatically calls
> the correct validator internally? After looking at the ValidationInterceptor
> I've had a try at calling a validator programmatically within my action with
>
> if (licenseId.endsWith("*")) {
>                         GenericLicenseValidator validator = new 
> GenericLicenseValidator();
>                         validator.setValidatorContext(new 
> DelegatingValidatorContext(this));
>                         validator.setFieldName("licenseId");
>                         try {
>                                 validator.validate(this);
>                         } catch (ValidationException e) {
>                                 e.printStackTrace();
>                         }
>                 }
>
> but this is giving me null pointer exceptions and I don't know if this is
> because my code is wrong or because it just insn't going to work. So if
> anyone could point me to examples of programmatically calling a validator I
> would appreciate it.
>
> Regards
>
>
>
>
> --
> View this message in context: 
> http://old.nabble.com/Struts-2-Conditional-Validators--tp30471468p30471468.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
>
>

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



Struts 2 Conditional Validators?

2010-12-16 Thread RogerV

Hi

Is it possible to "conditionally" trigger a validator such that if
conditionA then use ValidatorX else use ValidatorY within the validation
framework out of the box? 

I have a scenario where a user is entering a serial number as a license key.
They can either enter a full serial number which licenses a particular
machine, or they can enter a "generic" license number, for example "DEF*"
which licenses all machine of a particular model. These keys end up in the
same column in the database and there is a single "serial Number field" in
the data capture form and hence a single attribute in my action. And of
course, they need validating differently.

The obvious solution to create two seperate input fields on the .jsp form
has been vetoed by the client. I have tried calling two seperate methods and
attaching the validators to the individual methods like;

public String execute() {
if (licenseId.endsWith("*")) {
addGenericLicense(licenseId);
} else {
addSpecificLicense(licenseId);
}
return SUCCESS;
}

 

@CustomValidator(fieldName="licenseId",type="SpecificLicense",message="Invalid
License key")

private void addSpecificLicense(String licenseId) {
getNewUserDTO().addSpecificLicense(licenseId);

}


@CustomValidator(fieldName="licenseId",type="GenericLicense",message="Invalid
Generic License key")
private void addGenericLicense(String licenseId) {
getNewUserDTO().addGenericLicense(licenseId);

}

but that doesn't work either - it looks like when either method
(addGenericLicense() or addSpecificLicense() is executed, all the validators
for the field licenseId are called and both validators fire.

I could of course, just write a validate() method in my action, but I would
like to keep the validators as I can re-use them elsewhere, so if there's no
way to have an "either/or validator" through the framework, I was wondering
if there is way of "nesting" the validators. Something along the lines of
having one single validator for the license key that programmatically calls
the correct validator internally? After looking at the ValidationInterceptor
I've had a try at calling a validator programmatically within my action with 

if (licenseId.endsWith("*")) {
GenericLicenseValidator validator = new 
GenericLicenseValidator();
validator.setValidatorContext(new 
DelegatingValidatorContext(this));
validator.setFieldName("licenseId");
try {
validator.validate(this);
} catch (ValidationException e) {
e.printStackTrace();
}
}

but this is giving me null pointer exceptions and I don't know if this is
because my code is wrong or because it just insn't going to work. So if
anyone could point me to examples of programmatically calling a validator I
would appreciate it.

Regards




-- 
View this message in context: 
http://old.nabble.com/Struts-2-Conditional-Validators--tp30471468p30471468.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: execAndWait Interceptor

2010-12-16 Thread Zoran Avtarovski
Sorry about the delayed response. I have been busy with xmas crap (ba
humbug).

The way we implement an ajax solution is to create a new thread, with a flag
stored in the session and poll the server using a jquery ajax call every 10
seconds. The ajax call returns a json response which has the flag value as
its first item and then relevant data if the process is complete.

The beauty of this is we have no page refreshes and when the process is
complete use the ajax response to either display the info or a link to the
report.

Z.


On 14/12/10 7:06 PM, "RogerV"  wrote:

> 
> 
> 
> Sparecreative wrote:
>> 
>> We use the interceptor for interrogating a legacy database where we have
>> no control over the execution or timing of the query.
>> 
>> We basically have an API we call and then wait in hope.
>> 
>> I have to say that I've found the interceptor to be inconsistent at best.
>> 
>> For example we have some queries that are actually quite quick but the
>> interceptor insists on doing at least one page refresh before returning a
>> result. We've tried tweaking all the setting with absolutely no joy.
>> 
>> On the last project, we actually implemented an ajax solution which was
>> far more elegant result.
>> 
> 
> Are there any pointers or code samples available to show how to implement an
> ajax exec & wait?
> 
> Regards



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