Re: how to eliminate time in

2010-02-20 Thread Andy Sykes
You could write your own type converter - see type conversion in the S2 docs 
for a good overview. It handles the conversion of any Java object in your model 
class to a String for use in the view, and converts any String field into a 
Java object in forms/GET parameters.

That way you have total control over how the field appears without needing 
extra "type" getters (which is a bit hacky IMO).

- Original message -
> maybe you can write a js function to format it or you rewrite your
> getter method of startDate, in this method you will first format it
> then return it. the latter requires all the other caller of the method
> getStartDate needs the same format.
>
> On Sat, Feb 20, 2010 at 12:09 AM, wild_oscar  wrote:
> >
> > Aaah, dates!
> >
> > Add an s:date and associate with the textfield, like:
> >
> > 
> > 
> >
> > I'm not sure if both tags need the "name" or not - post your findings.
> >
> >
> > fireapple wrote:
> > >
> > > Does that mean I have to create something like:
> > >
> > > public String getStartDateStr()
> > > {
> > > ...
> > > }
> > >
> > > to do this?
> > >
> > > I don't want to use this because if I use this getter, I have to create a
> > > setter for this since user can edit the date.
> > >
> > > Any other options? Thanks
> > >
> > >
> > >
> > > Brian Thompson-5 wrote:
> > > >
> > > > Just add a getter to your "train" object that translates the startDate
> > > > into
> > > > the format you'd like.  Use a DateFormat object.
> > > >
> > > > -Brian
> > > >
> > > >
> > > >
> > > > On Thu, Feb 18, 2010 at 5:07 PM, fireapple 
> > > > wrote:
> > > >
> > > > >
> > > > > Dear all, I'm using
> > > > > 
> > > > >
> > > > > where startDate is a java.util.Date field of an object train.
> > > > >
> > > > > The output is something like this:
> > > > >
> > > > > http://old.nabble.com/file/p27647328/date.png
> > > > >
> > > > > How can I eliminate the 12:00:00 in the textfield? Thanks!
> > > > > --
> > > > > View this message in context:
> > > > > http://old.nabble.com/how-to-eliminate-time-in-%3Cs%3Atextfield%3E-tp27647328p27647328.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
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> > --
> > View this message in context:
> > http://old.nabble.com/how-to-eliminate-time-in-%3Cs%3Atextfield%3E-tp27647328p27655381.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
> >
> >
>
>
>
> --
> Life is irrational.
>
> -
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>



TypeConverters - multiple fields/values

2010-02-14 Thread Andy Sykes
Hi list,

I'm extending the StrutsTypeConverter and writing my own type converter. Is 
there any way to have the type converter reference multiple fields in order to 
construct a complex type?

I notice the method signature for convertFromString has three parameters - one 
of them is a String array of values. Is this a path to having multiple values 
associated with a single field? That would also provide a way of generating a 
complex type.

Thanks,
Andy.
 



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



Netbeans 6.7 RC3 and Struts2

2009-06-19 Thread Andy Sykes

Hi all,

Is anyone else using NB 6.7 RC3 and editing pages with S2 tags in them?

The tags seem to really screw up the editor's error parsing mechanism,  
leaving red lines under everything after an S2 tag (like  
), and giving an error of "missing ; before statement"  
which looks like a Javascript parser error.


Anyone else seeing this? If so, I'll report it as a bug.

Andy.


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



Re: Block accessing in some path with filter.

2009-05-21 Thread Andy Sykes
Read the section on the config file elements in struts.xml on the  
Struts2 docs site. Also read the Interceptors guide[1].


You have to specify the interceptor stack on the action. You can use  
the  element to specify what stack to use by  
default.


And what you've defined is not an interceptor stack - it's just an  
interceptor alone. What you want to do is specify something like this:



	class="com.mycompany.myproduct.AdminInterceptor"/>







That adds the admin interceptor to the bottom of the basic interceptor  
stack.


Look at the docs - you'll get a faster answer than coming to the  
mailing list with every question. They really are very good docs, as  
docs go.


Andy.

[1] http://struts.apache.org/2.x/docs/interceptors.html

On 21 May 2009, at 16:00, Stefano Tranquillini wrote:


thanks,

but i definide in struts my interceptors in this way:


  
  class="interceptors.AdminLogin"/>

  

in order to use the interceptors only when namespace is /admin/*

but the interceptor is never called!

And:


where i've to put the globalforward?
i putted a the end of the sturts.xml

something like that

 
   
   

has to be inside package or something else?

the error is:

2009-05-21 16:56:51,171 ERROR [com.opensymphony.xwork2.util.DomHelper]
(HDScanner) Element type "global-forwards" must be declared. at
(null:92:22)
org.xml.sax.SAXParseException: Element type "global-forwards" must  
be declared.




2009/5/21 Stefano :

2009/5/21 Paweł Wielgus :

global forward


thanks,

but i definide in struts my interceptors in this way:

 
   
   class="interceptors.AdminLogin"/>

   

in order to use the interceptors only when namespace is /admin/*

but the interceptor is never called!

ideas?

thanks

--
Stefano





--
Stefano

-
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



Re: Block accessing in some path with filter.

2009-05-20 Thread Andy Sykes
You need to include  elements in your filter mappings for  
the Struts filter.


eg.


struts2
/*
REQUEST
FORWARD


With no  element specified, the container assumes you mean  
the filter chain only gets applied to requests.


The FORWARD element means the filter chain  
will get invoked when a servlet performs a forward (as your code does).


Just FYI - you may want to consider doing your protection with  
Interceptors, since it's a bit less clumsy than lugging around servlet  
filters with Struts.


You can very easily write an Interceptor[1] that will return a certain  
result type (say "denied") based on whether a specified attribute  
exists in the user's session. Doing so is left as an exercise to the  
reader :)


You're not then limited to using mappings in the web.xml, and all the  
logic is embedded in the framework you've chosen.


Struts' interceptors are a very powerful AOP-style pattern that I  
think are sometimes overlooked and aren't emphasised enough...


[1] http://struts.apache.org/2.x/docs/writing-interceptors.html

On 20 May 2009, at 13:42, Stefano Tranquillini wrote:


now is taked. but i've some problem with the dispacer.
i've an action mapped in this way:
  
   denied
   

namespace is /

if i manually put in this url:
http://localhost:8080//WAP-Shop-war/denied.action its WORKS.

the filter, else branch is this:
else {
   RequestDispatcher rd = null;
   rd = sc.getRequestDispatcher("/denied.action");
   rd.forward(myRequest, myResponse);
   }

and has to recall the same url see above, but he returns an error  
(404):


type Status report

message /WAP-Shop-war/denied.action

description The requested resource (/WAP-Shop-war/denied.action) is
not available.

but is available!

ideas?



On Wed, May 20, 2009 at 13:35, Andy Sykes  wrote:
Put the mapping for the admin filter above the struts2 filter.  
Filters are

invoked in the order in web.xml, first to last.

The struts filter is catching the request first and dispatching it  
before it

ever reaches the admin filter.

On 20 May 2009, at 09:37, Stefano Tranquillini wrote:


Hi all.
i need to block the path /admin/ for all the pepole. only the people
logged in as root can access it.
i've done a filter, but struts seems to dosen't works with its

 
  struts2

org.apache.struts2.dispatcher.FilterDispatcherfilter-class>

  
  
  adminFilter
  filter.AdminFilter
  
  
  struts2
  /*
  
  
  adminFilter
  /admin/*
  

public class AdminFilter implements Filter {

  FilterConfig fc;

  public AdminFilter() {
  }

  public void init(FilterConfig fc) throws ServletException {
  this.fc = fc;
  }

  public void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain) throws IOException, ServletException {

  System.out.println("i'm the filter!");


  HttpServletResponse myResponse = (HttpServletResponse)  
response;

  HttpServletRequest myRequest = (HttpServletRequest) request;
  String user = (String)
myRequest.getSession().getAttribute("logged");
  ServletContext sc = fc.getServletContext();
  if (user.equals("admin")) {


  String requestURI = myRequest.getRequestURI();
  int pathLength = myRequest.getContextPath().length();
  StringBuffer relativeURI = new
StringBuffer(requestURI.substring(pathLength));
  String query = myRequest.getQueryString();
  if (query != null) {
  relativeURI.append("?").append(query);
  }
  RequestDispatcher rd = null;
  if (relativeURI.toString().length() > 0) {
  rd = sc.getRequestDispatcher(relativeURI.toString());
  } else {
  rd = sc.getRequestDispatcher("/WAP-Shop-war/");
  }
  rd.forward(myRequest, myResponse);
  } else {
  RequestDispatcher rd = null;
  rd = sc.getRequestDispatcher("/WAP-Shop-war/");
  rd.forward(myRequest, myResponse);
  }
  return;
  }

  public void destroy() {
  }
}


when i put the url like:
http://localhost:8080/WAP-Shop-war/admin/showAddItem.action i see  
the

page and i don't see the string: i'm the filter!

where's the fault?

--
Stefano

-
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






--
Stefano

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

Re: Block accessing in some path with filter.

2009-05-20 Thread Andy Sykes
Put the mapping for the admin filter above the struts2 filter. Filters  
are invoked in the order in web.xml, first to last.


The struts filter is catching the request first and dispatching it  
before it ever reaches the admin filter.


On 20 May 2009, at 09:37, Stefano Tranquillini wrote:


Hi all.
i need to block the path /admin/ for all the pepole. only the people
logged in as root can access it.
i've done a filter, but struts seems to dosen't works with its

  
   struts2
   org.apache.struts2.dispatcher.FilterDispatcherfilter-class>

   
   
   adminFilter
   filter.AdminFilter
   
   
   struts2
   /*
   
   
   adminFilter
   /admin/*
   

public class AdminFilter implements Filter {

   FilterConfig fc;

   public AdminFilter() {
   }

   public void init(FilterConfig fc) throws ServletException {
   this.fc = fc;
   }

   public void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain) throws IOException, ServletException {

   System.out.println("i'm the filter!");


   HttpServletResponse myResponse = (HttpServletResponse)  
response;

   HttpServletRequest myRequest = (HttpServletRequest) request;
   String user = (String)  
myRequest.getSession().getAttribute("logged");

   ServletContext sc = fc.getServletContext();
   if (user.equals("admin")) {


   String requestURI = myRequest.getRequestURI();
   int pathLength = myRequest.getContextPath().length();
   StringBuffer relativeURI = new
StringBuffer(requestURI.substring(pathLength));
   String query = myRequest.getQueryString();
   if (query != null) {
   relativeURI.append("?").append(query);
   }
   RequestDispatcher rd = null;
   if (relativeURI.toString().length() > 0) {
   rd = sc.getRequestDispatcher(relativeURI.toString());
   } else {
   rd = sc.getRequestDispatcher("/WAP-Shop-war/");
   }
   rd.forward(myRequest, myResponse);
   } else {
   RequestDispatcher rd = null;
   rd = sc.getRequestDispatcher("/WAP-Shop-war/");
   rd.forward(myRequest, myResponse);
   }
   return;
   }

   public void destroy() {
   }
}


when i put the url like:
http://localhost:8080/WAP-Shop-war/admin/showAddItem.action i see the
page and i don't see the string: i'm the filter!

where's the fault?

--
Stefano

-
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



Re: [S2] When/How are Actions Created?

2009-05-19 Thread Andy Sykes
1. It's created when the Struts dispatcher filter receives a request  
that matches an  element in the XML configuration file. Xwork  
handles the creation, I believe (Struts internal DI framework). You're  
running with Spring as the container, which mean Spring does the  
action creation based on the name in the "class" element of the  
 configuration - Spring matches this against a  element  
in the applicationContext.xml for your app.


2. When you create an object with "new", you're not creating it in a  
container - "new" is dumb. Spring is smart - when Struts asks Spring  
for an object (an action in this case), Spring can look at its XML and  
say "hey, I see an @Autowired in that class Struts wanted. I'd better  
work out what I need to inject in here". Spring manages the object  
creation, and so can create the object, then inject. "new" just  
creates it.


In this case, I'd guess you only have a single  element in the  
Spring configuration of type MyService. When Spring is asked to make  
the object, and encounters the @Autowired annotation, it'll try to  
find a  element that matches (based on name, type, and probably  
some other things I can't remember). In this case, it finds a   
with type MyService. Then it uses some method to inject it into the  
object Struts asked it for (I'm not 100% sure how it does it without  
public setters, but it's pretty much the same end result as having a  
public setter for MyService).


Think of Spring like a big object factory with instructions for how to  
make objects. Struts asked for an object; Spring looked at its  
blueprints and figured out how to put it together, then handed it to  
Struts. That's basically what DI/IoC containers do.


I'd recommend you read the guides on springsource.org, or try a book  
on Spring. I quite like Spring In Action, by Craig Walls & Ryan  
Breidenbach (published by Manning, I think).



On 19 May 2009, at 15:58, Asleson, Ryan wrote:



Hello,

Not sure if this is a Struts 2 or Spring question but I'll start here.

I'm using Struts 2 along with Spring 2.5.  In our Struts 2 Actions, we
use the @Autowired annotation to inject our service beans into the
Action class:

@Autowired
private MyService myService;

Note that we do *not* have a public setter method; just the @Autowired
annotation.

In our Spring config file, we have this tag which (supposedly) tells
Spring that autowiring will be used:



When an Action is executed all of the @Autowired dependencies have  
been

injected.  There's a lot of magic going on there so I have some
questions:

1.  How and when (and preferably, in what class) is the Action for a
request created?

2.  How and when does Spring inject the @Autowired dependencies into  
the

Action, especially considering there are no public setter methods for
the dependencies?  If I create an Action using the "new" operator none
of the dependencies are injected, but somehow when Struts 2 creates  
the

Action, the dependencies are injected.  How or when does this happen?
How does Spring "know" what to inject and when to do it?

Thank you!!!

-Ryan




Ryan Asleson | Lead Developer

BI | Technology Solutions Group

www.biworldwide.com 




Please consider the environment before printing.




This e-mail message is being sent solely for use by the intended  
recipient(s) and may contain confidential information.  Any  
unauthorized review, use, disclosure or distribution is prohibited.   
If you are not the intended recipient, please contact the sender by  
phone or reply by e-mail, delete the original message and destroy  
all copies. Thank you.



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



Re: File upload (jupload)--how to disable struts2' fileupload interceptor?

2009-05-16 Thread Andy Sykes
I can't see anywhere in the documentation (I've only had a quick skim  
of it) that says not mapping the Struts dispatcher to /* can be  
dangerous.. the only example I can see is if you're using Struts  
interceptors/actions for webapp security - in which case hitting a  
servlet directly might mean there's no session information to validate  
the user. That's a trivial matter, though.


I routinely map the Struts dispatcher filter to a set of URLs, usually  
when I'm mixing Struts actions with servlets like yourself.


Just map the dispatcher where you need it.

On 16 May 2009, at 17:27, jesse crossley wrote:



i have a similar problem, in that i need to disable the struts2 file
interceptor as well.

i have a pre-existing webapp that already does FileUpload from html to
servlets, but now that i've introduced struts2 into my application,  
file
uploads and, in fact, any form set to use the multipart mime type  
regardless
of whether a file is attached or not and regardless of destination  
will now

fail once it hits my servlets.

logging indicates that the JakartaMultiPartRequest is handling the  
form post
before my servlet gets to it.  of course, the reason i even have  
this log

instead of a great big exception is because i configured my webapp's
struts.properties to use it:

struts 
.multipart 
.parser 
=org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest


and i'm sure that the reason the multipart parser is taking a crack  
at the

file posting is because my web.xml allows the struts2 dispatcher to be
mapped to /*, as shown in all struts2 example apps i've come across:
 
   struts2

org.apache.struts2.dispatcher.FilterDispatcherclass>

 
 
   struts2
   /*
 

i only need struts under /security, but documentation indicates that  
not
using /* can be dangerous, but doesn't indicate in what way or what  
else to

do about it.

does anyone know how to disable it through struts configuration?

alternatively, if i'm in a Servlet and i hafta use the struts2  
multipart

handling, how can i get at the params that the JakartaMultiPartRequest
parses out?  are they put in the session or context somewhere?

thanks,
jesse crossley

--
View this message in context: 
http://www.nabble.com/File-upload-%28jupload%29--how-to-disable-struts2%27-fileupload-interceptor--tp23534189p23575425.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



Re: Submitting a Date to an Action

2009-05-01 Thread Andy Sykes
I wrote my own method based on having three select dropdown boxes for  
the date - day, month and year.


Rather than do it as a type converter, I did it as an interceptor,  
with three getters/setters in the action (getStartTime_Day,  
getStartTime_Month, getStartTime_Year). The interceptor uses  
reflection when it encounters a Date setter (with a suitable  
annotation) in the action to look up these fields and parse them into  
a Date for setting. Lets me do validation at the same time.


Andy.

On 1 May 2009, at 12:44, Richard Sayre wrote:


I think I am going to write my own.  After experimenting with the date
time picker it only seems to convert the date if its in this format
mm/dd/yy. In my application the user can choose their own date format.
When I have a format like 1 May 2009, the datetime picker value does
not get converted.  It is expecting to set a String instead of a Date.
I am still trying to get my own converter to work right.  If I get
something written I will share it with the group.



On Thu, Apr 30, 2009 at 10:19 PM, Zoran Avtarovski
 wrote:
That¹s exactly right but sometimes you want to use a format that  
isn¹t the
short format for the locale and I suspect that¹s what is happening  
with

Richard.

He has two choices, either configure his date time picker to  
produce the
date in the required format, or as suggested write your own  
converter. My
only concern with Matt¹s version is that the conversion exception  
is buried

which will have implications for validation.

Z.




Hi Richard,

Have a look at http://struts.apache.org/2.1.6/docs/type-conversion.html
It says that "dates - uses the SHORT format for the Locale  
associated with the

current request"

May be this will help.

Thank you.
Regards,
Kishan.G

Senior Software Engineer.
www.spansystems.com




-Original Message-
From: Richard Sayre [mailto:richardsa...@gmail.com]
Sent: Thursday, April 30, 2009 4:14 PM
To: Struts Users Mailing List
Subject: Re: Submitting a Date to an Action

Thank you.  I will give it a try.

On Thu, Apr 30, 2009 at 1:22 AM, Matt Jiang   
wrote:

Hi

It is nothing about date picker tag. You can have a Converter to  
convert

String to Date and vice versa.
Below is my implementation for your reference:
(For DateUtil, please replace with yours)

public class DateConverter extends StrutsTypeConverter {

 private static final String PATTERN =  
DateUtil.PATTERN__MM_DD;


 @Override
 /**
  * Converts one or more String values to the specified class.
  *
  * @param context the action context
  * @param values  the String values to be converted, such as  
those

submitted from an HTML form
  * @param toClass the class to convert to
  * @return the converted object
  */
 public Object convertFromString(Map context, String[] values,  
Class

toClass) {

   Date returnObject = null;
   String value = values[0];
   if (value != null && !value.trim().equals("")) {
 try {
   returnObject = DateUtil.parseDate(value, PATTERN);
 } catch (ParseException e) {
   // Just to ignore the parse exception
 }
   }
   return returnObject;
 }

 @Override
 /**
  * Converts the specified object to a String.
  *
  * @param context the action context
  * @param o   the object to be converted
  * @return the converted String
  */
 public String convertToString(Map context, Object o) {

   Date date = (Date) o;
   String formatedDate = DateUtil.dateFormater(date, PATTERN);
   return formatedDate;
 }
}



On Thu, Apr 30, 2009 at 1:19 AM, Richard Sayre

wrote:



I have an Action with a date attribute

private Date myDate;

public void setMyDate(Date myDate) {
this.myDate = myDate;
}

I have a form that has a date picker (not the struts 2 date  
picker)
that populates a text field.  When I submitt the form to my  
action the

property does not get set because Struts 2 is looking for
setMyDate(String myDate).

How do I tell Struts that the field is a Date?


Thank you,

Rich

-
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


-
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




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



Re: OGNL & DisplayTag = inappropriate expressions

2009-04-30 Thread Andy Sykes

Ah, of course. I forgot about that.

Thanks. Next time I'll remember to search the list first..

A.

On 30 Apr 2009, at 21:10, Musachy Barroso wrote:


The parameters interceptor has an attribute (excludeParams), that can
take a list of regular expressions. Any param whose name matches on of
the regex, will be ignored. We should make a FAQ out of this question.

musachy

On Thu, Apr 30, 2009 at 3:47 PM, Andy Sykes  wrote:

Hi all,

Is there a way to prevent OGNL from analysing GET parameters as  
expressions?


Reason for asking:

DisplayTag generates URLs like this: action?d-49653-p=2

I'm getting tons of errors in the log, where it looks like OGNL is  
trying to
evaluate this as: (d minus 49653 minus p). Naturally, this makes it  
throw
ognl.InappropriateExpressionException any time a user loads a page  
with a

DisplayTag table in it, which is incredibly annoying.

Thoughts?

Andy.

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






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

-
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



OGNL & DisplayTag = inappropriate expressions

2009-04-30 Thread Andy Sykes

Hi all,

Is there a way to prevent OGNL from analysing GET parameters as  
expressions?


Reason for asking:

DisplayTag generates URLs like this: action?d-49653-p=2

I'm getting tons of errors in the log, where it looks like OGNL is  
trying to evaluate this as: (d minus 49653 minus p). Naturally, this  
makes it throw ognl.InappropriateExpressionException any time a user  
loads a page with a DisplayTag table in it, which is incredibly  
annoying.


Thoughts?

Andy.

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



Re: pagination in struts2

2009-04-23 Thread Andy Sykes
I found I had to use the  tag to set the object in the request  
scope before displaytag could "see" it, since displaytag doesn't know  
about the Value Stack (maybe it should?). Confusingly, displaytag  
gives you that message if it can't see the variable you're  
referencing, as well as if the variable is empty.


eg. 

On 23 Apr 2009, at 17:11, Stefano Tranquillini wrote:


i done this:

this is the class taht create the list

   private List items = new ArrayList();
   private Integer resultSize;

   public AllItem() {
   }

   @Override
   public String execute() throws Exception {
  items= mgmt.getAllItem();
   resultSize=getItems().size();
   return SUCCESS;
   }

   public List getItems() {
   return items;
   }


   public Integer getResultSize() {
   return resultSize;
   }

this is the page

<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://displaytag.sf.net"; prefix="display" %>


   
   
   


the result is:
Nothing found to display.

On Thu, Apr 23, 2009 at 17:52, Stefano Tranquillini
 wrote:

emm i've a list in my session called items.

so i'd write
a ok, i'd understand, now works.

anyway, how can i create the page number below?


On Thu, Apr 23, 2009 at 17:40, Bhaarat Sharma   
wrote:

u have to first create TestList for the code to work

On Thu, Apr 23, 2009 at 11:36 AM, Stefano   
wrote:



when i put
<% request.setAttribute( "test", new TestList(2, false) ); %>

netbeans said: cannot find construtcto TestList(int,bool)

and the application goes in a exception:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 1 in the jsp file: /jsp/shop/shop.jsp
TestList cannot be resolved to a type
1: <% request.setAttribute( "test", new TestList(2, false) ); %>
2: <%@ taglib uri="/struts-tags" prefix="s" %>
3:
4:

idea?


2009/4/23 André Diniz :

It's just a sample pages...

2009/4/22 Dave Newton 

http://displaytag.sourceforge.net/1.2/ 
tut_externalSortAndPage.html


It pays to really spend some time looking over existing  
documentation;

it's
often quicker than waiting for someone on a list or forum to  
answer.


Dave


Bhaarat Sharma wrote:


jim,

I found this example




http://displaytag.homeip.net/displaytag-examples-1.2/example-paging.jsp?d-49653-p=1


it says "Ok, you have made a query that returns you back a  
list of 120
elements, but you don't want to show the user all 120 items at  
once,

you
want to allow them to page through the results (pretend 120 is  
really

1200

or 12000)."

they are iterating through a long 12000 record list and then  
just

putting
that into pages.  What I was looking for was something that  
would show

50
results of 12000 on first page then when NEXT is cliked, it  
against

goes

to
DB to get next 50 records.



On Wed, Apr 22, 2009 at 4:22 PM, Jim Kiley >

wrote:

 I found this within thirty seconds of clicking Dave's link:

http://displaytag.sourceforge.net/1.2/tut_sources.html

Note that the contents of this page are actually fairly  
freakin'

horrible
and should not be done on a grownup application.  But the  
instructions

are
right there and easy to find.

jk

On Wed, Apr 22, 2009 at 4:18 PM, Bhaarat Sharma >

wrote:

 I wanted to use it for the purpose so that when I click NEXT  
or 2nd

page

then again I go to the DB to fetch next set of 50 records.

but didnt see any examples of that sort

On Wed, Apr 22, 2009 at 4:13 PM, Dave Newton >

wrote:

 Stefano Tranquillini wrote:


 someone has experience with this tag?


i don't really understand how it works.

 What issues are you having? There are a number of  
tutorials and



examples



on


the site:

http://displaytag.sourceforge.net/1.2/tut_basic.html

Dave





-

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





--
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com






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





--
André Diniz
+55 (41) 9997-5567
e-mail alternativo: diniz...@msn.com





--
Stefano

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








--
Stefano





--
Stefano

-
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



Re: pagination in struts2

2009-04-22 Thread Andy Sykes
Have a look at the external sorting and pagination page[1] on the  
DisplayTag site. Also, take a look at the PaginatedList interface[2].


It takes a little bit to get your head around it.

If you get stuck, the displaytag lists are pretty good at helping with  
the common issues.


Andy.


[1] http://displaytag.sourceforge.net/1.2/tut_externalSortAndPage.html
[2] 
http://displaytag.sourceforge.net/1.2/displaytag/apidocs/org/displaytag/pagination/PaginatedList.html

On 22 Apr 2009, at 22:27, Bhaarat Sharma wrote:


jim,

I found this example

http://displaytag.homeip.net/displaytag-examples-1.2/example-paging.jsp?d-49653-p=1

it says "Ok, you have made a query that returns you back a list of 120
elements, but you don't want to show the user all 120 items at once,  
you
want to allow them to page through the results (pretend 120 is  
really 1200

or 12000)."

they are iterating through a long 12000 record list and then just  
putting
that into pages.  What I was looking for was something that would  
show 50
results of 12000 on first page then when NEXT is cliked, it against  
goes to

DB to get next 50 records.



On Wed, Apr 22, 2009 at 4:22 PM, Jim Kiley   
wrote:



I found this within thirty seconds of clicking Dave's link:
http://displaytag.sourceforge.net/1.2/tut_sources.html

Note that the contents of this page are actually fairly freakin'  
horrible
and should not be done on a grownup application.  But the  
instructions are

right there and easy to find.

jk

On Wed, Apr 22, 2009 at 4:18 PM, Bhaarat Sharma 
wrote:

I wanted to use it for the purpose so that when I click NEXT or  
2nd page

then again I go to the DB to fetch next set of 50 records.

but didnt see any examples of that sort

On Wed, Apr 22, 2009 at 4:13 PM, Dave Newton 
wrote:


Stefano Tranquillini wrote:


someone has experience with this tag?

i don't really understand how it works.



What issues are you having? There are a number of tutorials and

examples

on

the site:

http://displaytag.sourceforge.net/1.2/tut_basic.html

Dave



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








--
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com




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



Re: How to do matematical operation in jsp.

2009-04-22 Thread Andy Sykes
Abstract the HashMap behind another class that has a getTotal(Item  
key) method, and do the math in there (return item.prize * quantity).


Doing any math in the JSP feels dirty.

On 22 Apr 2009, at 13:16, Stefano Tranquillini wrote:

Because the items are stored in hashmap  item  
contains the

prize.
so, to know the total for each item i've to multplay item.prize with
quantity.

no more else.



On Wed, Apr 22, 2009 at 14:01, Dave Newton   
wrote:



Stefano Tranquillini wrote:

but i've only to display in a jsp the results, when i use that  
value i

compute it by the ejb.



Then why are you re-computing it in the JSP?

The point is only that floating-point math is inaccurate. If you  
don't

care, or are controlling the results of the math somehow, then fine.


Dave


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





--
Stefano



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



Re: recipes for 2.0.x?

2009-04-18 Thread Andy Sykes
DWR is bloody ace - don't know how that slipped under my radar. Cheers  
for the heads-up.


Andy.

On 17 Apr 2009, at 21:24, Musachy Barroso wrote:


I am not sure what the status of the DWR plugin is, but I don't think
it has changed much. The DWR plugin just hooks DWR with Struts 2,
nothing more, you will be using DWR out of the box, without magic
tags.

musachy

On Fri, Apr 17, 2009 at 3:56 PM, mitch gorman   
wrote:

Musachy Barroso wrote:
I am not sure it is related, but make sure "showLoadingText" is  
set to
false, for that causes all kind of problems in IE. if you are  
still in
development, hear *biased* advice and don't use the Dojo based  
tags :)




   yeah, i learned that lesson already.  ;)  i did come across
something two interesting things, although neither of them really  
fit my

situation or helped much.  one of them was that IE apparently doesn't
like it if you try to update a *part* of a table, like a single  
 or

something.  a  is probably okay, but anything more granular it
doesn't seem to like.
(https://issues.apache.org/jira/browse/TAPESTRY-1217;  i am shipping
down a complete table, but i've done that in other situations  
without a

problem.)

   the other is that turning off dojo compression may help.
(http://www.dojoforum.com/node/6529)  this, of course, doesn't  
apply in

2.0.14, since that's not even a valid  attribute (S:head, not
SX:head).  this page, though, did clue me in to try/catch in JS (i'm
definitely not a JS wiz, obviously), which at least let me know  
that my

own dump() function (lifted from the web; JS dump references listed
below) was throwing an error.  when i wrapped the guts of my dump()
function in the try/catch, i was then able to see that it was
encountering an error when attempting to dump the "c" object in a  
couple

places.  that object is basically the XMLHttpRequest object
(http://www.w3schools.com/ajax/ajax_xmlhttprequest.asp).

   as for dumping javascript objects, the simple solution, which my
original function was a modification of, is at
http://weblogs.asp.net/skillet/archive/2006/03/23/440940.aspx.  a  
more
complex dump() function, a "port" of the Cold Fusion  tag,  
is at
http://www.netgrow.com.au/files/javascript_dump.cfm .  that's what  
i'm

trying to make use of, now.

   dave, i saw your response, too.  i looked at the 2.0.14, 2.0.11,  
and

even 2.0.8 recipes page, and they all had the newer  tags,
specifically the .  i really do wish i had access to that
sx:bind for what i'm doing... would've made so many things i've
done/tried to do in this app *so* much easier...

   musachy, going back to your (moderately biased) advice... before i
started my current job, i was doing some work with DWR v2.0 (even  
made

some small contributions to the project).  i know there's a dwr
plugin... would that cover everything i'm currently using the dojo  
tags
for?  would that be my best bet for a replacement, once i do  
finally get

time to migrate to struts v2.1.x?


--
Mitch Gorman
mgor...@shadowtv.com
(215) 764-6310
Skype: mitch.shadowtv.com


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






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

-
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



Re: recipes for 2.0.x?

2009-04-17 Thread Andy Sykes
Out of interest (and sorry for slight thread hijacking) - what's so  
bad about the Dojo tags?


Now the Dojo stuff is deprecated, is there a roadmap to replacing them  
with something else?


On 17 Apr 2009, at 20:30, Musachy Barroso wrote:


I am not sure it is related, but make sure "showLoadingText" is set to
false, for that causes all kind of problems in IE. if you are still in
development, hear *biased* advice and don't use the Dojo based tags :)

musachy

On Fri, Apr 17, 2009 at 1:37 PM, mitch gorman   
wrote:
   is there still a v2.0.x-specific recipes page, anywhere?  (i'm  
still
in dev-crunch mode, and can't take the hit to upgrade to v2.1.x,  
yet.)

my issue isn't truly a struts problem, per se, but i thought i might
find some help in debugging it in a 2.0-specific recipes page...


   specifically, i'm trying to update a div via ajax.  it works in  
FF3,

but not IE7.  i've put a notifyTopics="/change" on the button that
triggers the update, and i'm subscribing to the topic with the  
following

function:

   
   dojo.event.topic.subscribe("/change", function(a, b, c){
   alert(b);
   alert(dump(a));
   alert(dump(c));
   });
   

   i capture a before event, with a equal to "change" and c equal to
'cancel' with the value "false".  then i get the load event, with  
object
a containing the output from the JSP i'm trying to load as a  
string. (c
is not defined in either IE7 or FF3, yet it does seem to have a  
value in

both chrome and safari - bizarre!)

   then, in IE7, i catch an error event, and the dump of object a  
shows

the following:
'message' => "XMLHttpTransport.watchInFlight Error: [object Error]"
'type' => "unknown"
'number' => "0"

   i do *not* get that error event in FF3 (or chrome, or safari,
although chrome doesn't handle things correctly, either).  what i  
need

is to find out more details about that ajax error object, but i don't
know how to access it.

   anyone have any ideas how i can proceed with my debugging?

   TIA.

--
Mitch Gorman
mgor...@shadowtv.com
(215) 764-6310
Skype: mitch.shadowtv.com


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






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

-
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



and parameters

2009-04-16 Thread Andy Sykes

Hi all,

How can I use parameters passed in to a jsp file with  in a  
Struts2 tag within that JSP?


So for example, I want to include a big chunk of boilerplate HTML and  
pass in an image name, then use that passed-in name in an  tag  
to reference it.


Include:

prettything.jpg


The docs suggest using ${param.paramname}, which doesn't work -  
"According to TLD, value does not accept any expressions".


i.e. ">

I feel like I'm missing something incredibly obvious here..

Andy.


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



Pagination and s:subset

2009-03-20 Thread Andy Sykes

Hi list,

After bodging my way through some pagination for a project I'm working  
on with a combination of OGNL expressions, s:subset and s:iterator, I  
was wondering if anyone had given any serious thought to the  
practicality of implementing displaytag-style pagination in S2 tags?


Display tag is fabulous if you're working in tables; if you're not,  
it's a pain in the butt. You either have to roll your own pagination,  
which is a drag, or do a kludgy hack based on TableDecorators. If I'm  
missing something, please let me know!


I've not brain-mapped exactly how I'd go about it, but I'm fairly sure  
of the general idea. Has anyone thought through this and seen  
potential show-stoppers?


Cheers,
Andy.

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



Re: Casting an action to an interface

2009-01-30 Thread Andy Sykes
I'd love to zip up the whole project and stick it somewhere but it's  
pretty dependent on the environment I'm running it in (LDAP server for  
auth, etc etc). I could probably produce a neutered version of it  
that'll run anywhere, but it'll take a while as it's quite big..


As for classloaders, here's my debug statements:
	log.info("ParseInterceptor's class loader is:" +  
ParseInterceptor.class.getClassLoader().toString());
	log.info("Action's class loader is: " +  
action.getClass().getClassLoader().toString());
	log.info(action.getClass().getClassLoader() ==  
ParseInterceptor.class.getClassLoader());


And the output:

INFO ParseInterceptor - ParseInterceptor's class loader  
is:WebappClassLoader

  delegate: false
  repositories:
/WEB-INF/classes/
--> Parent Classloader:
org.apache.catalina.loader.standardclassloa...@fa7e74

15:36:08,198 INFO ParseInterceptor - Action's class loader is:  
WebappClassLoader

  delegate: false
  repositories:
/WEB-INF/classes/
--> Parent Classloader:
org.apache.catalina.loader.standardclassloa...@fa7e74

15:36:08,198 INFO ParseInterceptor - true

Suggests to me they're getting loaded by the same classloader.  
Something bloody funky is going on and I'm probably going to just roll  
the interceptors functionality into an action instead, but  
intellectual curiosity remains to be satisfied as to what the funk is  
causing this.


Cheers for the help,
Andy.

On 30 Jan 2009, at 15:03, Dave Newton wrote:

If you have a small project you could host somewhere that might  
help, or just zip up all the source. Clearly this can't happen  
(ignoring for the moment that it is), but the framework obviously  
relies on this working so I'd have to assume something funky is  
going on.


Dave

Andy Sykes wrote:
I dug around in the ServletConfig interceptor  and modified my code  
to mimic how it handles this situation - retrieve the Action as an  
Object type, test for instanceof , the cast to it. For  
some reason, that still does not work.
As a test case, I'm mimicking the code exactly. My action extends  
ActionSupport and implements SessionAware.
In the interceptor, I retrieve the action as an Object, test if  
it's an instanceof SessionAware, then cast. Logging statements show  
that the cast never happens. If I try to skip the test and cast  
directly, I get a CCE. However, the ServletConfigInterceptor is  
able to do exactly the same thing without getting a CCE.
Either there's some messed up going on in my dev environment, or  
I'm being really dumb, or.. god knows. I've cleared out all the old  
libraries and I'm just running with the bare essentials.

Test case:
public class ParseInterceptor extends AbstractInterceptor {
   private static final Logger log =  
Logger.getLogger(ParseInterceptor.class);

   @Override
   public String intercept(ActionInvocation invocation) throws  
Exception {

   final Object action = invocation.getAction();
   if (action instanceof SessionAware) {
   log.error("Action is an instance of SessionAware.");
   }
   return invocation.invoke();
   }
}
For reference, the relevant sections in the ServletConfigInterceptor:
public class ServletConfigInterceptor extends AbstractInterceptor  
implements StrutsStatics {
   public String intercept(ActionInvocation invocation) throws  
Exception {

   final Object action = invocation.getAction();
   final ActionContext context =  
invocation.getInvocationContext();

   ...snip...
   if (action instanceof SessionAware) {
   ((SessionAware)  
action).setSession(context.getSession());

   }
   }
}
On 30 Jan 2009, at 12:22, Andy Sykes wrote:
No, I don't 'need' the cast to Action. However, if I cast what I  
get back from ActionInvocation.getAction() straight to  
SessionAware or similar, it still chucks a CCE.


I'm using Netbeans, and I'm pretty sure there's no crazy stuff  
going on with the classloader - all my struts jars are in my  
context's lib directory.


On 30 Jan 2009, at 11:57, Nils-Helge Garli Hegvik wrote:

Do you really need the first cast to Action? Anyway, could it be  
that

you're having conflicting struts and/or application jars several
places in your classloader hierarchy? That could explain certain
"should never happen" incidents...

Nils-H

On Fri, Jan 30, 2009 at 12:39 PM, Andy Sykes   
wrote:

Hi Wes,

No, I'm not using Spring at all.

The Action never passes the test of being an instanceof  
Parseable. If I make
the action only implement SessionAware, and test if my action is  
an

instanceof SessionAware, the test is never passed!

Colour me confused!

Andy.


On 30 Jan 2009, at 00:55, Wes Wannemacher wrote:


On Thursday 29 January 2009 19:49:39 Andy Sykes wrote:


Hi 

Re: Casting an action to an interface

2009-01-30 Thread Andy Sykes
I dug around in the ServletConfig interceptor  and modified my code to  
mimic how it handles this situation - retrieve the Action as an Object  
type, test for instanceof , the cast to it. For some  
reason, that still does not work.


As a test case, I'm mimicking the code exactly. My action extends  
ActionSupport and implements SessionAware.
In the interceptor, I retrieve the action as an Object, test if it's  
an instanceof SessionAware, then cast. Logging statements show that  
the cast never happens. If I try to skip the test and cast directly, I  
get a CCE. However, the ServletConfigInterceptor is able to do exactly  
the same thing without getting a CCE.


Either there's some messed up going on in my dev environment, or I'm  
being really dumb, or.. god knows. I've cleared out all the old  
libraries and I'm just running with the bare essentials.


Test case:
public class ParseInterceptor extends AbstractInterceptor {

private static final Logger log =  
Logger.getLogger(ParseInterceptor.class);


@Override
public String intercept(ActionInvocation invocation) throws  
Exception {

final Object action = invocation.getAction();
if (action instanceof SessionAware) {
log.error("Action is an instance of SessionAware.");
}
return invocation.invoke();
}
}


For reference, the relevant sections in the ServletConfigInterceptor:

public class ServletConfigInterceptor extends AbstractInterceptor  
implements StrutsStatics {


public String intercept(ActionInvocation invocation) throws Exception {
final Object action = invocation.getAction();
	final ActionContext context =  
invocation.getInvocationContext();

...snip...
if (action instanceof SessionAware) {
((SessionAware) 
action).setSession(context.getSession());
}
    }
}
On 30 Jan 2009, at 12:22, Andy Sykes wrote:

No, I don't 'need' the cast to Action. However, if I cast what I get  
back from ActionInvocation.getAction() straight to SessionAware or  
similar, it still chucks a CCE.


I'm using Netbeans, and I'm pretty sure there's no crazy stuff going  
on with the classloader - all my struts jars are in my context's lib  
directory.


On 30 Jan 2009, at 11:57, Nils-Helge Garli Hegvik wrote:


Do you really need the first cast to Action? Anyway, could it be that
you're having conflicting struts and/or application jars several
places in your classloader hierarchy? That could explain certain
"should never happen" incidents...

Nils-H

On Fri, Jan 30, 2009 at 12:39 PM, Andy Sykes   
wrote:

Hi Wes,

No, I'm not using Spring at all.

The Action never passes the test of being an instanceof Parseable.  
If I make

the action only implement SessionAware, and test if my action is an
instanceof SessionAware, the test is never passed!

Colour me confused!

Andy.


On 30 Jan 2009, at 00:55, Wes Wannemacher wrote:


On Thursday 29 January 2009 19:49:39 Andy Sykes wrote:


Hi all,

I've written an interceptor with a PreResultListener that gets the
action with ActionInvocation.getAction(), then casts it to an
interface ("Parseable", in this case). This lets me call a  
particular

method on the action just prior to the result being rendered.

The action implements Parseable and SessionAware.

When I do the cast, I get an ClassCastException for
com.opensymphony.xwork2.ActionSupport. If I take it down to one
interface (SessionAware) and cast the action to it, I still get  
a CCE.
What's weirder is I'm pretty sure this code worked on Struts  
2.0.11.


Here's a suitably simplified version of what I'm attempting to do:

public String intercept(ActionInvocation invocation) throws  
Exception {

 invocation.addPreResultListener(new PreResultListener() {
   public void beforeResult(ActionInvocation invocation,
String resultCode) {
 Action action = (Action)invocation.getAction();
 if (action instanceof Parseable) {
 ((Parseable)action).parse();
 }
   }
 });

Any ideas what the hell is going on here?




Is it possible that you are using Spring to instantiate your  
actions via

the
Spring plugin? It would seem that if the action passes the test,  
then the

cast
is legal. I ask about Spring in case the action is a proxied  
bean... It

comes
up from time to time that Spring created beans don't always seem to
inherit
every method that you would think... If Spring is in the mix, try  
having
Spring use CGLIB... I've had some luck that way, vs. dynamic JDK  
proxies.


-Wes

--

Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh  
and more

http://www.manning.com/wannemacher



Re: Casting an action to an interface

2009-01-30 Thread Andy Sykes
No, I don't 'need' the cast to Action. However, if I cast what I get  
back from ActionInvocation.getAction() straight to SessionAware or  
similar, it still chucks a CCE.


I'm using Netbeans, and I'm pretty sure there's no crazy stuff going  
on with the classloader - all my struts jars are in my context's lib  
directory.


On 30 Jan 2009, at 11:57, Nils-Helge Garli Hegvik wrote:


Do you really need the first cast to Action? Anyway, could it be that
you're having conflicting struts and/or application jars several
places in your classloader hierarchy? That could explain certain
"should never happen" incidents...

Nils-H

On Fri, Jan 30, 2009 at 12:39 PM, Andy Sykes   
wrote:

Hi Wes,

No, I'm not using Spring at all.

The Action never passes the test of being an instanceof Parseable.  
If I make

the action only implement SessionAware, and test if my action is an
instanceof SessionAware, the test is never passed!

Colour me confused!

Andy.


On 30 Jan 2009, at 00:55, Wes Wannemacher wrote:


On Thursday 29 January 2009 19:49:39 Andy Sykes wrote:


Hi all,

I've written an interceptor with a PreResultListener that gets the
action with ActionInvocation.getAction(), then casts it to an
interface ("Parseable", in this case). This lets me call a  
particular

method on the action just prior to the result being rendered.

The action implements Parseable and SessionAware.

When I do the cast, I get an ClassCastException for
com.opensymphony.xwork2.ActionSupport. If I take it down to one
interface (SessionAware) and cast the action to it, I still get a  
CCE.
What's weirder is I'm pretty sure this code worked on Struts  
2.0.11.


Here's a suitably simplified version of what I'm attempting to do:

public String intercept(ActionInvocation invocation) throws  
Exception {

  invocation.addPreResultListener(new PreResultListener() {
public void beforeResult(ActionInvocation invocation,
String resultCode) {
  Action action = (Action)invocation.getAction();
  if (action instanceof Parseable) {
  ((Parseable)action).parse();
  }
}
  });

Any ideas what the hell is going on here?




Is it possible that you are using Spring to instantiate your  
actions via

the
Spring plugin? It would seem that if the action passes the test,  
then the

cast
is legal. I ask about Spring in case the action is a proxied  
bean... It

comes
up from time to time that Spring created beans don't always seem to
inherit
every method that you would think... If Spring is in the mix, try  
having
Spring use CGLIB... I've had some luck that way, vs. dynamic JDK  
proxies.


-Wes

--

Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and  
more

http://www.manning.com/wannemacher


-
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




-
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



Re: Casting an action to an interface

2009-01-30 Thread Andy Sykes

Hi Wes,

No, I'm not using Spring at all.

The Action never passes the test of being an instanceof Parseable. If  
I make the action only implement SessionAware, and test if my action  
is an instanceof SessionAware, the test is never passed!


Colour me confused!

Andy.


On 30 Jan 2009, at 00:55, Wes Wannemacher wrote:


On Thursday 29 January 2009 19:49:39 Andy Sykes wrote:

Hi all,

I've written an interceptor with a PreResultListener that gets the
action with ActionInvocation.getAction(), then casts it to an
interface ("Parseable", in this case). This lets me call a particular
method on the action just prior to the result being rendered.

The action implements Parseable and SessionAware.

When I do the cast, I get an ClassCastException for
com.opensymphony.xwork2.ActionSupport. If I take it down to one
interface (SessionAware) and cast the action to it, I still get a  
CCE.

What's weirder is I'm pretty sure this code worked on Struts 2.0.11.

Here's a suitably simplified version of what I'm attempting to do:

public String intercept(ActionInvocation invocation) throws  
Exception {

invocation.addPreResultListener(new PreResultListener() {
  public void beforeResult(ActionInvocation invocation,
String resultCode) {
Action action = (Action)invocation.getAction();
if (action instanceof Parseable) {
((Parseable)action).parse();
}
  }
});

Any ideas what the hell is going on here?




Is it possible that you are using Spring to instantiate your actions  
via the
Spring plugin? It would seem that if the action passes the test,  
then the cast
is legal. I ask about Spring in case the action is a proxied bean...  
It comes
up from time to time that Spring created beans don't always seem to  
inherit
every method that you would think... If Spring is in the mix, try  
having
Spring use CGLIB... I've had some luck that way, vs. dynamic JDK  
proxies.


-Wes

--

Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and  
more

http://www.manning.com/wannemacher


-
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



Casting an action to an interface

2009-01-29 Thread Andy Sykes

Hi all,

I've written an interceptor with a PreResultListener that gets the  
action with ActionInvocation.getAction(), then casts it to an  
interface ("Parseable", in this case). This lets me call a particular  
method on the action just prior to the result being rendered.


The action implements Parseable and SessionAware.

When I do the cast, I get an ClassCastException for  
com.opensymphony.xwork2.ActionSupport. If I take it down to one  
interface (SessionAware) and cast the action to it, I still get a CCE.  
What's weirder is I'm pretty sure this code worked on Struts 2.0.11.


Here's a suitably simplified version of what I'm attempting to do:

public String intercept(ActionInvocation invocation) throws Exception {
invocation.addPreResultListener(new PreResultListener() {
  public void beforeResult(ActionInvocation invocation,  
String resultCode) {

Action action = (Action)invocation.getAction();
if (action instanceof Parseable) {
((Parseable)action).parse();
}
  }
});

Any ideas what the hell is going on here?


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



Re: Only call actions from certain forms

2009-01-24 Thread Andy Sykes
Doh. I was being very stupid - I looked in the XWork source and  
realised it's really straightforward.


I'm blaming this one of lack of sleep :)

Cheers,
Andy.

On 25 Jan 2009, at 01:25, Wes Wannemacher wrote:


On Saturday 24 January 2009 20:17:49 Andy Sykes wrote:

Actually, having an interceptor makes some sense in this case.

How can interceptors "short circuit" the stack and action to return a
result code? The ideal situation here would be that the "protector"
interceptor is above the validation interceptor, checks for the form
token, and chucks an error result code, protecting the validators  
from

null parameters and so on.



Well, the invoke method returns a string indicating which result to  
dispatch
to. Take a look at a few of the other interceptors to see. For  
instance, if

validation fails, the validation interceptor returns "input".


I can't see anything in the documentation about achieving this - the
ActionInvocation javadoc suggests that
ActionInvocation.setResultCode() will not short-circuit the stack,  
and

that the action's own result code will override the interceptor-set
result.



When an interceptor calls invocation.invoke() it either moves to the  
next
interceptor, or calls the method, depending on where it is in the  
stack. It

fairly intuitive.

--

Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and  
more

http://www.manning.com/wannemacher


-
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



Re: Only call actions from certain forms

2009-01-24 Thread Andy Sykes

Actually, having an interceptor makes some sense in this case.

How can interceptors "short circuit" the stack and action to return a  
result code? The ideal situation here would be that the "protector"  
interceptor is above the validation interceptor, checks for the form  
token, and chucks an error result code, protecting the validators from  
null parameters and so on.


I can't see anything in the documentation about achieving this - the  
ActionInvocation javadoc suggests that  
ActionInvocation.setResultCode() will not short-circuit the stack, and  
that the action's own result code will override the interceptor-set  
result.


Andy.

On 24 Jan 2009, at 17:56, Dave Newton wrote:


Andy Sykes wrote:
Cheers for the suggestions - I guess I was just looking for a  
sanity check from the list.


It seems reasonable to me--the functionality *could* be wrapped up  
in an interceptor, which might be marginally cleaner, but it's one  
of those judgment calls that in real life I probably wouldn't care  
much about.


The reasoning behind wanting to do this is my users are somewhat  
curious, and are prone to poking. I'd prefer for them to not see  
blank pages, stack traces, or otherwise!


Darn users... this is a pretty typical requirement and is one of the  
reason workflow "engines" came about; they can handle simple cases  
like this as well as disallowing jumps into the middle of multi-step  
processes etc.


Dave


-
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



Re: Upgrading Struts 2

2009-01-24 Thread Andy Sykes

Hi,

We've migrated an app from 2.0.11 to 2.1.2 (and then to 2.1.6 when it  
became GA - this was a trivial upgrade).


I found this article on the Apache wiki very useful: 
http://cwiki.apache.org/S2WIKI/troubleshooting-guide-migrating-from-struts-20x-to-21x.html

I had no major issues - and the performance of app 'seemed' a bit  
quicker (I've done no definitive tests, but the 'feel' was of snappier  
rendering). The only problem I ran into was where I had some nasty  
hack for passing dynamic parameters to an action through redirect- 
action - I was doing it in a non-standard way, which worked in 2.0.11.  
It was a quick fix to change it to the proper way to do it.


Andy.

On 24 Jan 2009, at 13:42, Matthew Seaborn wrote:

We are currently running 2.0.11 and having been away from Struts 2  
for a while I was pleased to a see a number of new releases.


Has anyone done an upgrade to either 2.0.14 or 2.1.6 from a 2.0.x  
release?   If so how smooth was the transition?


Matthew Seaborn
Software Architect
t+44(0) 208 484 0729
m  +44(0) 7949 465 142
e   matthew.seab...@performgroup.com

Sussex House
Plane Tree Crescent
London, TW13 7HE
United Kingdom
www.performgroup.com







CONFIDENTIALITY - This email and any files transmitted with it, are  
confidential, may be legally privileged and are intended solely for  
the use of the individual or entity to whom they are addressed. If  
this has come to you in error, you must not copy, distribute,  
disclose or use any of the information it contains. Please notify  
the sender immediately and delete them from your system.


SECURITY - Please be aware that communication by email, by its very  
nature, is not 100% secure and by communicating with Perform Group  
by email you consent to us monitoring and reading any such  
correspondence.


VIRUSES - Although this email message has been scanned for the  
presence of computer viruses, the sender accepts no liability for  
any damage sustained as a result of a computer virus and it is the  
recipient’s responsibility to ensure that email is virus free.


AUTHORITY - Any views or opinions expressed in this email are solely  
those of the sender and do not necessarily represent those of  
Perform Group.


COPYRIGHT - Copyright of this email and any attachments belongs to  
Perform Group, Companies House Registration number 6324278.




Re: Only call actions from certain forms

2009-01-23 Thread Andy Sykes

Hi all,

Cheers for the suggestions - I guess I was just looking for a sanity  
check from the list.


My current method (almost exactly the same as below) is to check a  
choice form field for null in the validateXXX() method - this is the  
case when you call the action without POST from a form. If null, I can  
return INPUT from the validation method (which, interestingly enough,  
lets me set the return type as String, and have it honoured as a valid  
result - I thought void was the only valid validateXXX result type).  
The input result kicks the user to the form they should've used. Job  
done.


I'm not using XML or annotation validators - 95% of my validation is  
more complex than those allow.


The reasoning behind wanting to do this is my users are somewhat  
curious, and are prone to poking. I'd prefer for them to not see blank  
pages, stack traces, or otherwise!


Andy.

On 24 Jan 2009, at 02:52, Dave Newton wrote:


Andy Sykes wrote:
My forms all submit to a different action than that which renders  
the pages.
Is there a recommended way to prevent/mitigate the effect of users  
directly calling the actions (via their URL) that forms are  
submitted to? In this case, the actions' fields are null, which is  
somewhat irritating in an action method that has associated  
validation..


The simplest solution, although somewhat hacky, might be to just  
check for a hidden form token in the action's validate method. If  
it's not there, it wasn't reached from the form. If it is, call  
super.validate() which will run any XML/annotation-based validation.


Dave


-
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



Only call actions from certain forms

2009-01-23 Thread Andy Sykes

Hi all,

My forms all submit to a different action than that which renders the  
pages.


Is there a recommended way to prevent/mitigate the effect of users  
directly calling the actions (via their URL) that forms are submitted  
to? In this case, the actions' fields are null, which is somewhat  
irritating in an action method that has associated validation..


Andy.

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



Re: OGNL exceptions are swallowed by struts2

2009-01-09 Thread Andy Sykes
If you're running with log4j in your app, set the logging priority on  
the root logger to debug. It spews a lot of messages, and the type  
converter messages are there - I was using this facility the other day  
when trying to upgrade an existing app from 2.0.x to 2.1.2.


Andy.

On 9 Jan 2009, at 09:12, Robert Graf-Waczenski wrote:


Hi!

To my knowledge, you have to enable devMode. This gives you a lot of  
debugging output and exception stack traces on the console. The  
drawback is that it makes your application rather sluggish.


Yes, the article you quote is well known. I agree, Struts2 sucks big  
time in this regard while being an excellent framework otherwise.


Robert

Vincent Lin wrote:

Hi,

Is there anyway to get better error message there's an error  
occurring in

ognl?

Everytime there's an exception in ognl it's swallowed.

And I ran into some "No Result Found for XxxAction" error.

It's extremely hard to debug, because there's no any useful  
information in

it.

All of them seem to be converter related problem.

Is there anyway to make struts 2 easier to debug?

There's an article complaining about this issue:
http://raibledesigns.com/rd/entry/does_struts_2_suck

Thanks,
Vincent





-
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



Re: preparable inceptor and validation

2008-12-16 Thread Andy Sykes

Hi,

My simple solution to the same problem was to check if any validation  
errors had occurred at the end of the validation method [with  
hasFieldErrors()], then call my prepareXXX method from there.



On 16 Dec 2008, at 05:39, srinivasa_v . wrote:


Hi All,
I have sistutation  where I need to return to entryForm, if there any
validation errors,but before going to entryform for second time,
I need to get some prepopulated data , for this I am  using preparable
inceptor,

I am able to get my prepopulated data fine,
but the I am not able to see my action errors,

If I  try to remove preparable inceptor , it working fine,and no
prepopulated data

can any one help me

regards
srini..



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



Re: alignment problem in struts2

2008-12-16 Thread Andy Sykes

Hi,

No idea why it doesn't work - I found the XHTML theme to be a bit  
cumbersome for anything other than a stack of fields, one on top of  
the other.


Use the simple theme - it'll give you more flexibility. You can write  
your own themes as well.


For getting the validation errors in the simple theme, use the  
 tag.


Andy.

On 16 Dec 2008, at 10:17, VSG wrote:



Hi Manikanta,
   I have gone throgh the documents.
   so,With the default(XHTML) theme Im unable to put two fileds in  
the same

row?
   Can u pls tell why?
   Could u provide me a solution.

 i try to see with the following lines of code
  
  
  


 but it is not working.
is it the correct way?

VSG





ManiKanta G-2 wrote:




 It should appear in the same row.But the problem is here it is
apperaing
in two rows.
 Which i want in one row.And the same thing with the buttons  
cancel and

reset button should appear in   same row.



If u've seen the S2 docs, S2 uses templates/themes while  
constructing the

views.
By default XHTML theme will be used.

See
http://struts.apache.org/2.x/docs/why-do-the-form-tags-put-table-tags-around-controls.html
http://struts.apache.org/2.x/docs/themes-and-templates.html

ManiKanta




--
View this message in context: 
http://www.nabble.com/alignment-problem-in-struts2-tp21029381p21030443.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



Re: Validation and dispatcher

2008-12-13 Thread Andy Sykes
I guess I'm going to answer my own question here, though the fact that  
my question seems extremely ungoogleable(!) suggests I'm going about  
this ass-backwards...


What I did was check hasFieldErrors() at the end of validation method  
of the form submission - if true, then I just rebuild my objects for  
use in the form. Then when Struts2 uses the dispatcher to send me back  
to the form JSP, the objects the form needs are in value stack.


I'm guessing the objects don't persist into the action after form  
submission because Struts is just blindly calling the setters and  
getters for the form fields, and doesn't give a crap about stuff in  
the value stack - it's not going to read them all and call the setters  
and getters for those as well.


If anyone else is doing something similar, it would be nice to know I  
haven't gone totally insane.


Andy.

On 13 Dec 2008, at 16:26, Andy Sykes wrote:


Hi all,

I've got an action called "edit" that prepares some objects for use  
in a form (Lists for select tags, etc), then dispatches to the JSP  
form. It's dependent on having a parameter passed to it via a GET  
url (e.g. edit.action?id=4) to build these objects.


This form submits to another action, "doedit", and there's some  
programmatic validation on this action. If I use the Dispatcher  
result type on the input result, Struts dispatches to the JSP form  
again, but since it never calls the first "edit" action, the form  
controls don't get populated. If I do redirect-action on the input  
result, I get back to the form, but Struts seems to have "forgotten"  
the FieldErrors object, so I get no validation messages.


How do you deal with validation when you're using actions to prepare  
forms like this? Am I approaching the rich forms generation the  
wrong way, and there's a better way?


Thanks for any advice, since I'm banging my head against the wall on  
this - I must be missing something obvious.


Cheers,
Andy.

--
Andy Sykes
IT Support Officer
UCL Museums & Collections /
Media Resources
a.sy...@ucl.ac.uk

Room 225, 2nd Floor
Wilkins Building
(Mon/Tues/Wed AM)
Tel: 0207 679 67667 | x37667

Charles Bell House
43-45 Foley Street
(Wed PM/Thurs/Fri)
Tel: 0207 679 99164 | x09164






-
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



Validation and dispatcher

2008-12-13 Thread Andy Sykes

Hi all,

I've got an action called "edit" that prepares some objects for use in  
a form (Lists for select tags, etc), then dispatches to the JSP form.  
It's dependent on having a parameter passed to it via a GET url (e.g.  
edit.action?id=4) to build these objects.


This form submits to another action, "doedit", and there's some  
programmatic validation on this action. If I use the Dispatcher result  
type on the input result, Struts dispatches to the JSP form again, but  
since it never calls the first "edit" action, the form controls don't  
get populated. If I do redirect-action on the input result, I get back  
to the form, but Struts seems to have "forgotten" the FieldErrors  
object, so I get no validation messages.


How do you deal with validation when you're using actions to prepare  
forms like this? Am I approaching the rich forms generation the wrong  
way, and there's a better way?


Thanks for any advice, since I'm banging my head against the wall on  
this - I must be missing something obvious.


Cheers,
Andy.

--
Andy Sykes
IT Support Officer
UCL Museums & Collections /
Media Resources
a.sy...@ucl.ac.uk

Room 225, 2nd Floor
Wilkins Building
(Mon/Tues/Wed AM)
Tel: 0207 679 67667 | x37667

Charles Bell House
43-45 Foley Street
(Wed PM/Thurs/Fri)
Tel: 0207 679 99164 | x09164






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



Re: redirection problem with name is input

2008-12-12 Thread Andy Sykes
I could be wrong, but I thought you could only pass the FieldErrors  
back to a JSP using a dispatcher result, not a redirect-action.


Andy.

On 12 Dec 2008, at 12:34, Seshagiri V wrote:




Hi All,

Mapping with redirection type and name is "input" and value is null  
but I am

not able to validations errors in jsp.

Please follow code.

class 
= 
"org.paradigmpop.mypopproject.waterhole.actions.AddEditWaterholeAction

">

 

   viewPoPIndex.actionparam>


   /p

 

 

   viewAddEditWaterhole.action

   /p

   ${waterholeDTO.teamPoP.popid}

 



   



class 
= 
"org.paradigmpop.mypopproject.waterhole.actions.ViewAddEditWaterholeAc

tion">

 

   viewPoPWaterhole.action

   /p/wa

 





Thank you,

Seshagiri V

seshagi...@kensium.com.



US Main: 877 KENSIUM (536.7486)

US Fax:   312.242.3029



Kensium

200 S Wacker Dr, Suite 3100

Chicago, IL 60606



Confidentiality Note:

-

The information contained in this e-mail is strictly confidential  
and for
the intended use of the addressee only. Any disclosure, use or  
copying of
the information by anyone other than the intended recipient is  
prohibited.


If you have received this message in error, please notify the sender
immediately by return e-mail and securely discard this message.








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



Re: Please help! Validation Errors

2008-12-10 Thread Andy Sykes

Faraz,

I think at this point some code would help. Could you post your  
struts.xml, and the action?


Andy.

On 10 Dec 2008, at 17:16, Faraz Ali wrote:

Yes Andy, you are right. I added the , but why  
it is

executing automatically. It is executed automatically when i start my
application.

On Wed, Dec 10, 2008 at 6:19 PM, Andy Sykes <[EMAIL PROTECTED]> wrote:


Faraz,

When using validation, the input result tells Struts where to
dispatch/redirect to if there's a validation error. When you submit  
the
form, Struts checks the fields against the validation XML - if  
there's an
error, it adds FieldError objects to the FieldErrors object on the  
value
stack, and dispatches to the JSP (or other resource) defined in the  
input

result element. This is nearly always the JSP containing the form you
submitted from.

You have to have a  because Struts has to know  
where

to redirect in the event of a validation error.

Not sure what you mean by the last bit of your question..

Andy.



On 10 Dec 2008, at 05:56, Faraz Ali wrote:

13:45:18,390 ERROR [ActionComponent] Could not execute action:

/web/MyAction
No result defined for action com.web.actions.MyAction and result  
input -

action - file:/C:/
jboss-4.2.3.GA/server/default/tmp/deploy/tmp35854MyWeb-exp.war/WEB- 
<http://jboss-4.2.3.ga/server/default/tmp/deploy/tmp35854MyWeb-exp.war/WEB- 
>

INF/classes/struts.xml:12:69

1. I have a simple Action class MyAction
2. A corresponding MyAction-validation.xml present in same  
location as

Action class
3.  is included in jsp
4. No  is present

My Question is why do we need this input element? Because i want to
control
it my way. And if i add this input element, its opening the jsp  
page at

the
start of the application. Can anybody help me how to do validation
properly
in struts2 application?

--
Best Regards,
Faraz Ali




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--
Best Regards,
Faraz Ali



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Please help! Validation Errors

2008-12-10 Thread Andy Sykes

Faraz,

When using validation, the input result tells Struts where to dispatch/ 
redirect to if there's a validation error. When you submit the form,  
Struts checks the fields against the validation XML - if there's an  
error, it adds FieldError objects to the FieldErrors object on the  
value stack, and dispatches to the JSP (or other resource) defined in  
the input result element. This is nearly always the JSP containing the  
form you submitted from.


You have to have a  because Struts has to know  
where to redirect in the event of a validation error.


Not sure what you mean by the last bit of your question..

Andy.


On 10 Dec 2008, at 05:56, Faraz Ali wrote:

13:45:18,390 ERROR [ActionComponent] Could not execute action: /web/ 
MyAction
No result defined for action com.web.actions.MyAction and result  
input -

action - file:/C:/
jboss-4.2.3.GA/server/default/tmp/deploy/tmp35854MyWeb-exp.war/WEB- 
INF/classes/struts.xml:12:69


1. I have a simple Action class MyAction
2. A corresponding MyAction-validation.xml present in same location as
Action class
3.  is included in jsp
4. No  is present

My Question is why do we need this input element? Because i want to  
control
it my way. And if i add this input element, its opening the jsp page  
at the
start of the application. Can anybody help me how to do validation  
properly

in struts2 application?

--
Best Regards,
Faraz Ali



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]