Indexed Tags?

2013-07-01 Thread Eric Lentz
I recently posted a question here regarding using tags that refer to a List
or an array structure in the action class, such as is depicted below.

I was told that I should be using indexed tags. Googling for that
specific phrase is not providing me with what that is and no joy in finding
it in the Struts book I own either.

Can someone please explain to me what an indexed tag is?

--- Example of original question context ---
s:iterator value=foos status=stat 
s:textfield name=foos[%{#stat.index}].aString
value=%{foos[#stat.index].aString} /
/s:iterator

- Eric


Consistency?

2013-06-27 Thread Eric Lentz
My questions are: Is there a better place to discuss this? Could this ever
be enhanced?

The issue:
I'd love to see more consistency in the way we must access indexed values
when iterating. Consider the example below and note that there are 3
distinct ways in which I must access the index value. I can't tell you how
many times this has caused errors (and wasted time). Any chance that this
could be revised in some later version of Struts so there is just 1 way to
access in every attribute of every Struts element?

s:iterator value=foos status=stat 

s:textfield name=foos[%{#stat.index}].aString
value=%{foos[#stat.index].aString} /

s:property value=foos[#stat.index].aString /

/s:iterator

Summary:
1: foos[%{#stat.index}].aString
2: %{foos[#stat.index].aString}
3: foos[#stat.index].aString

Anyone else grieved by this or am I doing something wrong?

- Eric


Re: Consistency?

2013-06-27 Thread Eric Lentz
Good discussion. Thanks guys. Some replies:

Chris: No joy on using the second form on all.
Dave:
 How would you propose to make them the same but end up with different
results?

I understand what you're saying and get it. You're clear depiction of the
separation of tasks is helpful. Maybe I'm just not a fan of building an
expression within an attribute and it has been confusing for those for whom
I've introduced Struts 2. I'd rather that OGNL was there to figure out how
to access beans by way of getter/setter and Struts know that if I put
foos[n].aString in a value tag that I actually want a value (getters)
versus putting the same thing in the name tag that I'm intending to write
to fields (setters). That's what I want a framework for: To figure things
out for me so I don't have to work (or think) so hard. I've been using
Struts 2 for years and only just recently realized that # referred to a
context! Maybe I'm just dense, but it has taken awhile to really grasp all
the moving parts.

It's a trade-off. Part of me still wants the power of OGNL (though I don't
find I use more than even a fraction of its power), but if I had to pick, I
think I'd go for simplicity for the typical use case which I believe I'm
illustrating.

Dave/Eric R:
What do you mean by indexed tags?

- Eric

On Thu, Jun 27, 2013 at 6:04 PM, Eric Reed ere...@mail.nysed.gov wrote:

 I agree, you should be using indexed tags, and they are two different
 things as Dave has stated.


  Dave Newton davelnew...@gmail.com 6/27/2013 5:19 PM 
 On Thu, Jun 27, 2013 at 4:38 PM, Eric Lentz  ericle...@outfastsource.com
 wrote:

  s:textfield name=foos[%{#stat.index}].aString
  value=%{foos[#stat.index].aString} /
 

 Here you're doing to explicitly different things:

 1. Provide a name (a string) with an embedded expression evaluation.
 2. Execute an OGNL expression to retrieve a value.

 Normalizing these things to be the same thing makes no sense, because
 they're different things and must be treated as such. How would you propose
 to make them the same but end up with different results?


  s:property value=foos[#stat.index].aString /
 

 Here you're choosing not to explicitly wrap the OGNL expression in %{}.

 IIRC there's an option to force the use of %{}, but  this is the same thing
 as in the value attribute above, you'd just decided not to wrap it in the
 OGNL escape.

 At best there are two different things, and I'm not really sure how they
 could be the same thing if they're used manually as values.

 The *actual* solution is to provide indexed tags.

 Dave


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




Re: Strategy for navigation in struts 1.2

2013-04-15 Thread Eric Lentz
Requirement 4 seems a little (unnecessarily?) restrictive. You obviously
need to store the information somewhere. Why not the session?

If not in the session or a cache, then the database would be the next
likely candidate, in my opinion. You'll have to manage it by clearing
information after you use it. If you used the session, worst case, it would
be cleared once the session was invalidated due to timeout, for example.

You could also possibly use cookies. Again, you'd need to manage these in
the event that someone comes back.

Those are pretty much the usual suspects.

Regarding:
So far i am passing calling page as reference to this add page, and then
using java script forward the action back to calling page.

In Struts 1, is this safe? Thread-safe, that is. You might be safer to load
relevant information into a DTO and pass that around as method parms,
thereby making it thread-safe. Once again, you're using server memory to do
this, so why not put it into the session?

- Eric

On Mon, Apr 15, 2013 at 11:27 AM, Ashish ashi...@samarthinfo.com wrote:

 Hi
 I have a question about designing strategy for page navigation, this is my
 requirement

 1. There is a add new information page which can be called from 5 different
 pages.
 2. When the addition is successful return the calling page
 3. when returning to calling page, maintain search criteria on calling
 page, for
 example if on calling page search criteria is set then when this page is
 displayed it should maintain those search criteria.
 4. Not to use session to save form information which can be used for
 maintaining
 search criteria

 These are main requirements,


 1. So far i am passing calling page as reference to this add page, and then
 using java script forward the action back to calling page.

 2. How to maintain this search criteria for each page?



 Ashish


OGNL time sink - combining two variables with ()

2013-02-26 Thread Eric Lentz
I'm approving of Struts 2 and encourage its use, but I have 1 main
complaint: OGNL. Here's an example.

Context:

s:iterator var=reviewer  // value is a List of a domain object
#reviewer.reviewerStatus   // equals R

s:set var=isAdmin value=true /

When I do this:
s:if test='#reviewer.reviewerStatus == R'
I get into the if condition. This is good.

When I do this:
s:if test='isAdmin'
I get into the if condition. This is also good.


When I do this:
s:if test='isAdmin  #reviewer.reviewerStatus == R'
I DO NOT get into the if condition.

I also tried:
s:if test='isAdmin==true  #reviewer.reviewerStatus == R'
s:if test='isAdmin==true  #reviewer.reviewerStatus == R'
s:if test='isAdmin and #reviewer.reviewerStatus == R'
reordering the variables around 
using equals()

None work.

So I go to the OGNL website to make sure I'm doing this right and I get a
404 when I try to get the language guide:
The requested URL /proper/commons-lang/uage-guide.html was not found on
this server.

My feeling is that OGNL has always been the ugly step sister in Struts 2.
It feels like OGNL, as a framework, has been a hot potato and nobody really
WANTS to maintain it and grow it into the powerful utility it could be. Any
time I have ever wasted time trying to do something that should be simple,
I can usually point back to OGNL as the culprit. /my opinion/minor rant

Anyway, any ideas on what I'm doing wrong?


Re: OGNL time sink - combining two variables with ()

2013-02-26 Thread Eric Lentz
Got it!

s:if test='#reviewer.reviewerStatus == R  #isAdmin'

Just needed the # on isAdmin. Sigh.


On Tue, Feb 26, 2013 at 10:36 AM, Eric Lentz ericle...@outfastsource.comwrote:

 I'm approving of Struts 2 and encourage its use, but I have 1 main
 complaint: OGNL. Here's an example.

 Context:

 s:iterator var=reviewer  // value is a List of a domain object
 #reviewer.reviewerStatus   // equals R

 s:set var=isAdmin value=true /

 When I do this:
 s:if test='#reviewer.reviewerStatus == R'
 I get into the if condition. This is good.

 When I do this:
 s:if test='isAdmin'
 I get into the if condition. This is also good.


 When I do this:
 s:if test='isAdmin  #reviewer.reviewerStatus == R'
 I DO NOT get into the if condition.

 I also tried:
 s:if test='isAdmin==true  #reviewer.reviewerStatus == R'
 s:if test='isAdmin==true  #reviewer.reviewerStatus == R'
 s:if test='isAdmin and #reviewer.reviewerStatus == R'
 reordering the variables around 
 using equals()

 None work.

 So I go to the OGNL website to make sure I'm doing this right and I get a
 404 when I try to get the language guide:
 The requested URL /proper/commons-lang/uage-guide.html was not found on
 this server.

 My feeling is that OGNL has always been the ugly step sister in Struts 2.
 It feels like OGNL, as a framework, has been a hot potato and nobody really
 WANTS to maintain it and grow it into the powerful utility it could be. Any
 time I have ever wasted time trying to do something that should be simple,
 I can usually point back to OGNL as the culprit. /my opinion/minor rant

 Anyway, any ideas on what I'm doing wrong?




Re: Why Struts2 doesn't have string value trimming ?

2013-02-19 Thread Eric Lentz
You can specify an interceptor-ref per action. Your file upload could point
to a different interceptor stack.

If interceptor is the only option can anyone tell which will be the safest
 way to achieve this without disturbing other struts default filter like
 fileUpload.




Re: usage of ${...}

2013-01-15 Thread Eric Lentz
It appears that the relevant portion of your code example is this:
li id=user-s:property value=#user.id/-${id}

#user.id gives you the id, right? Do you want it twice?

You also have  s:iterator value=#request.users var=user
Did you put request into the context? The typical pattern would be to
have users on the ValueStack by way of your action class which has a
private field called users (presumably type ListUser, or similar), and
a getter for users.

#user.id looks okay within the property tag assuming that the source you
are iterating over is available. ${id} should not be available unless you
have such a field in your action (but it would be the same for each
iteration). That said, I don't really use ${} very much, so YMMV.


Extending base class and accessing implementation's fields in Struts 2

2012-12-03 Thread Eric Lentz
I have
ListBaseObject foo

The list is of type BaseObjectImpl

BaseObject has fields:
String a
String b

BaseObjectImpl has fields:
String c
String d

Now I'm in a JSP and want to iterate foo (using s:iterator), accessing
fields c and d (inside iterator using s:property, for example). How? As
far as Struts knows I'm dealing with BaseObject. Is there a way for me to
cast to BaseObjectImpl without creating a StrutsTypeConverter for every
object I'm extending? In my use case, there will be several and the
temptation is to just define the list with the implementation which foils
reusability patterns (e.g., ListBaseObjectImpl).

Likewise, what to do when posting back to a field like this:
BaseObject bar  (which has BaseObjectImpl as its implementation) e.g.,
s:textfield name=bar.c /


Is there a totally different approach that would be better or is
StrutsTypeConverter the only good answer?

- Eric


Re: Extending base class and accessing implementation's fields in Struts 2

2012-12-03 Thread Eric Lentz
I'm almost there. I didn't suspect that it would work that way with the
iterator. Should have tried it first! Thanks Dave.

On the way back, such as in a post, if BaseObject is an interface or
abstract, as I'm hoping for it to be, then Struts tries to instantiate the
BaseObject type, which it can't, so it throws:

[com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler] Could
not create and/or set value back on to object
java.lang.InstantiationException
at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
 at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
at java.lang.Class.newInstance0(Class.java:350)
 at java.lang.Class.newInstance(Class.java:303)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:130)
 at
com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.createObject(InstantiatingNullHandler.java:159)
at
com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler.nullPropertyValue(InstantiatingNullHandler.java:137)
 at
com.opensymphony.xwork2.ognl.OgnlNullHandlerWrapper.nullPropertyValue(OgnlNullHandlerWrapper.java:21)
at ognl.ASTProperty.getValueBody(ASTProperty.java:118)
...etc.

Any ideas on solving that?

- Eric

On Mon, Dec 3, 2012 at 11:19 AM, Eric Lentz ericle...@outfastsource.comwrote:

 I have
 ListBaseObject foo

 The list is of type BaseObjectImpl

 BaseObject has fields:
 String a
 String b

 BaseObjectImpl has fields:
 String c
 String d

 Now I'm in a JSP and want to iterate foo (using s:iterator), accessing
 fields c and d (inside iterator using s:property, for example). How? As
 far as Struts knows I'm dealing with BaseObject. Is there a way for me to
 cast to BaseObjectImpl without creating a StrutsTypeConverter for every
 object I'm extending? In my use case, there will be several and the
 temptation is to just define the list with the implementation which foils
 reusability patterns (e.g., ListBaseObjectImpl).

 Likewise, what to do when posting back to a field like this:
 BaseObject bar  (which has BaseObjectImpl as its implementation) e.g.,
 s:textfield name=bar.c /


 Is there a totally different approach that would be better or is
 StrutsTypeConverter the only good answer?

 - Eric




Best way to add to ValueStack in an Interceptor

2012-11-30 Thread Eric Lentz
Inside of an interceptor, I'd like to add a value onto the the ValueStack.
What is the best way to do this?

I tried this:
invocation.getStack().set(myValueStackName, theValueIwantForThisName);

But that pushes that value to the top of the stack, pushing my action class
down which becomes problematic for values getting assigned to the action
class. For example, a JSP field with name=fooId and an action class with
a field of Long fooId. When I have the above code, fooId doesn't get
assigned. When I don't, it works as you would expect.

I guess my interceptor could be later in the stack of interceptors, after
the ParametersInterceptor, but that seems fragile. Some other developer
could come along and move it and now there are bugs. Plus, I'd prefer this
particular interceptor be at or near the beginning of the list of
interceptors.

So, how do I assign, but leave the action class at the top of the stack? I
could pop the action, add my value and then add the action back on, but is
there a better way?

- Eric


Re: Best way to add to ValueStack in an Interceptor

2012-11-30 Thread Eric Lentz
Maurizio, tried your way and no joy. Looks like I'll go with Łukasz' way.

Thanks everyone for your consideration and help!

On Fri, Nov 30, 2012 at 1:31 PM, Lukasz Lenart lukaszlen...@apache.orgwrote:

 2012/11/30 Eric Lentz ericle...@outfastsource.com:
  Inside of an interceptor, I'd like to add a value onto the the
 ValueStack.
  What is the best way to do this?
 
  I tried this:
  invocation.getStack().set(myValueStackName, theValueIwantForThisName);
 
  But that pushes that value to the top of the stack, pushing my action
 class
  down which becomes problematic for values getting assigned to the action
  class. For example, a JSP field with name=fooId and an action class
 with
  a field of Long fooId. When I have the above code, fooId doesn't get
  assigned. When I don't, it works as you would expect.

 use stack.pop() and stack.push()

  I guess my interceptor could be later in the stack of interceptors, after
  the ParametersInterceptor, but that seems fragile. Some other developer
  could come along and move it and now there are bugs. Plus, I'd prefer
 this
  particular interceptor be at or near the beginning of the list of
  interceptors.
 
  So, how do I assign, but leave the action class at the top of the stack?
 I
  could pop the action, add my value and then add the action back on, but
 is
  there a better way?

 No, this is the preferred way. And please keep in mind the stack will
 be searched from top to down for given value name.


 Regards
 --
 Łukasz
 + 48 606 323 122 http://www.lenart.org.pl/

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




Re: Best way to add to ValueStack in an Interceptor

2012-11-30 Thread Eric Lentz
Good call Chris! I didn't realize that. The context solution Maurizio
offered now works for me. Pros/cons to both
approaches. The context approach could be confusing to the uninitiated on
the UI side. Pop/push could be confusing or mysterious at the interceptor
level (again, for the casual Struts coder). The context solution will be
the quickest for me (already done), so I guess that's the winner of the
coin toss.

Thanks again everyone!


On Fri, Nov 30, 2012 at 2:15 PM, Chris Pratt thechrispr...@gmail.comwrote:

 Remember, when you use Maurizio's way, you have to reference the values as
 context, not stack variables. So instead of using %{myvar} you have to use
 %{#myvar).
   (*Chris*)


 On Fri, Nov 30, 2012 at 10:42 AM, Eric Lentz ericle...@outfastsource.com
 wrote:

  Maurizio, tried your way and no joy. Looks like I'll go with Łukasz' way.
 
  Thanks everyone for your consideration and help!
 
  On Fri, Nov 30, 2012 at 1:31 PM, Lukasz Lenart lukaszlen...@apache.org
  wrote:
 
   2012/11/30 Eric Lentz ericle...@outfastsource.com:
Inside of an interceptor, I'd like to add a value onto the the
   ValueStack.
What is the best way to do this?
   
I tried this:
invocation.getStack().set(myValueStackName,
  theValueIwantForThisName);
   
But that pushes that value to the top of the stack, pushing my action
   class
down which becomes problematic for values getting assigned to the
  action
class. For example, a JSP field with name=fooId and an action class
   with
a field of Long fooId. When I have the above code, fooId doesn't get
assigned. When I don't, it works as you would expect.
  
   use stack.pop() and stack.push()
  
I guess my interceptor could be later in the stack of interceptors,
  after
the ParametersInterceptor, but that seems fragile. Some other
 developer
could come along and move it and now there are bugs. Plus, I'd prefer
   this
particular interceptor be at or near the beginning of the list of
interceptors.
   
So, how do I assign, but leave the action class at the top of the
  stack?
   I
could pop the action, add my value and then add the action back on,
 but
   is
there a better way?
  
   No, this is the preferred way. And please keep in mind the stack will
   be searched from top to down for given value name.
  
  
   Regards
   --
   Łukasz
   + 48 606 323 122 http://www.lenart.org.pl/
  
   -
   To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
   For additional commands, e-mail: user-h...@struts.apache.org
  
  
 



Re: Reuse Struts2 Actions for thick clients

2012-04-02 Thread Eric Lentz
This was recently discussed. You may want to review that thread [1] and
then post any follow-up questions you may have.

[1] http://markmail.org/thread/znyl2ervtnlbb5tn


Re: Struts 2.3.1.2 and Spring 3.1.1 integration in wls 10.3.4 server

2012-03-28 Thread Eric Lentz
Did you turn on logging? What is the caught exception?


On Wed, Mar 28, 2012 at 11:01 AM, Rout, Biswajit biswajit.r...@hp.comwrote:

 Hi,
 I am running Struts 2.3.1.2 and Spring 3.1.1 integration in wls 10.3.4
 server. However the validation framework is not working.
 Please find the log and the xml file.



 Log Information

 Mar 28, 2012 3:34:42 PM
 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
 SEVERE: Caught exception while loading file
 com/gm/gm3pd/registration/action/RegistrationAction-validation.xml
 Tried all: '1' addresses, but could not connect over HTTP to server: '
 www.opensymphony.com', port: '80' - Class: weblogic.net.http.HttpClient
 File: HttpClient.java
 Method: openServer
 Line: 321 - weblogic/net/http/HttpClient.java:321:-1


 RegistrationAction-validation.xml

 !DOCTYPE validators PUBLIC
 -//OpenSymphony Group//XWork Validator 1.0.2//EN
 http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd;

 validators
 field name=firstname
 field-validator type=requiredstring
  message key=requiredstring/
 /field-validator
 /field
 field name=password
 field-validator type=requiredstring
  message key=requiredstring/
 /field-validator
 /field
 field name=password
 field-validator type=stringlength
 param name=minLength5/param
 param name=maxLength15/param
 param name=trimtrue/param
 message Please enter Min %{minLength} character or Max %{maxLength}
 Character /message
 /field-validator
 /field
 /validators

 Any hints on the above issue.
 Thanks in advance.



 Best regards,
 Biswajit
 Planned Vacation : From 2-July-2012 to 6-July-2012




Re: Action mapping - match on anything

2012-03-24 Thread Eric Lentz
Looks like it will! How did I manage to miss that? It was right there on
the same page I referred to! Thanks Paweł!

On Fri, Mar 23, 2012 at 4:20 PM, Paweł Wielgus poulw...@gmail.com wrote:

 Hi Eric,
 maybe this will help:

default-action-ref name=cover/default-action-ref

 Best regards,
 Paweł Wielgus.





Action mapping - match on anything

2012-03-23 Thread Eric Lentz
Anyone know of a way, in Struts 2, to assign an action that matches on
anything in the URL, including slashes? This would be a catch-all, if no
other action specification is more specific.

I configured:
constant name=struts.enable.SlashesInActionNames value=true /
constant name=struts.mapper.alwaysSelectFullNamespace value=false/
constant name=struts.action.extension value=/

If I have action name=* ...
then it will match on http://server/context/foo
but it will not match on http://server/context/foo/bar

I could do something like this action name=*/* ...
but then I'd need to do that for every combination, and I want to be able
to have n slashes; as is needed (which will vary).

I tried regex, but that requires that I have some kind of {foo} notation
for it to execute a regex. Maybe there's still a way to make that work, but
my imagination has run out on possibilities. OGNL does a bunch of
complaining if the string supplied in the URL doesn't match what's in the
parens in some way.

I see [1] talks about a catch-all mapping, as specified above, but again,
no joy on the slashes.

[1] http://struts.apache.org/2.0.11.1/docs/action-configuration.html


XStream Version

2012-03-21 Thread Eric Lentz
Would it be this forum or somewhere else that I would suggest an upgrade to
which version of XStream Struts 2 uses? I recently started using it for
development not related to Struts 2, and found that the version being used
is 1.2.2, which was released in May of 2007 [1][2]. I upgraded to 1.4.2,
the latest[3], and haven't had any issues with Struts although I have not
exhaustively tested and certainly haven't run any Struts core unit tests.
Having a newer version would make it easier to utilize within the same web
app. for which I'm running Struts 2.

So, please let me know if there is some action I need to take to pass along
this suggestion.

[1] http://repo1.maven.org/maven2/com/thoughtworks/xstream/xstream/1.2.2/
[2] http://xstream.codehaus.org/changes.html
[3] http://xstream.codehaus.org/download.html


Re: Using Spring parentContext to inject common dependencies is injecting dont expected values

2012-03-19 Thread Eric Lentz
 As i have read, struts only works with autowired context, dont know why 
but it's ok.

I'm not able to take time to read and understand your whole question, but 
this premise, upon which your question appears to be built, is incorrect. 
I use Spring and Struts 2 together, all of the time, and I never use 
autowiring, but I'm also not using annotations. I configure through a XML 
file. I call the bean whatever I want to call it and then use that name in 
the place of the class name in the struts.xml. Maybe that little bit of 
information can help you? 

Re: Wizard (multipage flow) with Struts 2

2012-02-01 Thread Eric Lentz
 Has anyone developed Wizard in Struts 2 without using Spring webflow 
plugin.

I have done it with and without jQuery, but find that the jQuery form 
wizard plug-in [1] is by far the easiest. In short, you create a div each 
to represent each step and add class=step to the div, and you're pretty 
much done as far as the wizard coding is considered. The plug-in handles 
breaking the form into multiple wizard steps. Then the wizard pages look 
like 1 big form to Struts 2 when the last page is submitted (the plug-in 
handles making the last page a submit). Validations can be handled via the 
validation plug-in. You probably want a paranoid validation step at the 
action level. If there is an error there, that the jQuery validation 
didn't catch, then there was probably some outside manipulation (if you 
did validations correctly) and a generic error message, outside of the 
wizard, would be acceptable and probably never seen by the average user.

If you don't use jQuery, then just store the object you're dealing with 
(model) in the session and iteratively update it at the end of each wizard 
step. If there is more than just the one model object, then store a DTO in 
the session and call that your model. That's essentially how I did it 
anyway, without going into every gory detail which I don't really have 
time for.

[1] http://thecodemine.org/



Re: File download fails in Firefox and Chrome

2012-01-13 Thread Eric Lentz
 Not setting the Content-disposition is header, makes the firefox to 
prompt for the download but it uses the action for filename ie 
Ticket.action.  Has anyone faced a similar issue or can provide a hint on 
how to fix the issue

Yep, saw this problem just this week.

I ran the request through software that would allow me to view the header 
and I saw that only the filename appeared in the contentDisposition, no 
filename=...
Add a field to your action class called contentDisposition and assign it 
like this:
contentDisposition = filename=\ + filename + \;

This assumes you are using the stream result in a manner similar to this:
result name=myDownloadName type=stream
param name=bufferSize1024/param
/result

I included the contentDisposition in the result like this:

result name=myDownloadName type=stream
param name=contentType${contentType}/param
param 
name=contentDispositionfilename=${contentDisposition}/param
param name=bufferSize1024/param
/result

But that didn't work, because Struts took whatever was in my 
contentDisposition in my action versus using the param. So _the above 
doesn't work_ because it would drop the filename= portion. If you used a 
different variable name, then it would probably work, but I didn't go back 
and try. In theory, this would work:

result name=myDownloadName type=stream
param name=contentType${myContentType}/param
param 
name=contentDispositionfilename=${myContentDisposition}/param
param name=bufferSize1024/param
/result

Assuming you had myContentType and myContentDisposition in your action.

Hope that helps.

Re: File download fails in Firefox and Chrome

2012-01-13 Thread Eric Lentz
 I was working with no issue until a month ago for over a year and 
suddenly it has stopped working

I get that. Best thing to do would be to view the headers from a client 
that can do so. There are plug-ins in Firefox that will allow that I 
believe. I think you'll find that something is amiss with the header even 
though it appears you have it set correctly. I see from your last e-mail 
that you have it fixed though, so moot point I guess.

Re: How to compare string reference variables using ognl?

2011-12-12 Thread Eric Lentz
When you use a value from the set tag you'll need to prefix with the '#' 
as per the documentation [1]

I've definitely used equals in the past and know it works (although not in 
the property tag like you are, but should be the same as in s:if; OGNL 
either way)

Something like this might work:
s:property value=#selectedOffer.equals(#queryString)/

But why use set at all? Just use the source variables:
s:property value=ecOffers.dicountKey.equals(#entry.key)/

I don't believe this will work for the reason you site. equals is the way 
to go.
s:property value='#selectedOffer==#queryString'/

[1] - http://struts.apache.org/2.2.1/docs/set.html



From:   mohan rao mohanara...@gmail.com
To: user@struts.apache.org
Date:   12/12/2011 09:24 AM
Subject:Re: How to compare string reference variables using ognl?



s:set var=selectedOffer value=%{ecOffers.dicountKey}/
s:iterator var =entry value = #session.discountOffers
s:set var=queryString value=%{#entry.key}/
s:property value=selectedOffer.equals(queryString)/  It supposed to
print true or false. But not printing any value

s:property value='#selectedOffer==#queryString'/ Printing false even 
they
are same. (I think it's checking reference.)

--
View this message in context: 
http://struts.1045723.n5.nabble.com/How-to-compare-string-reference-variables-using-ognl-tp5060783p5067525.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: [OT] Searching for data access framework.

2011-12-05 Thread Eric Lentz
 abstract the data call and its source

Not a Struts question, but an easy answer, so here you go:

http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html

Use a Data Access Object (DAO) to abstract and encapsulate all access to 
the data source. The DAO manages the connection with the data source to 
obtain and store data.


Re: [OT] Searching for data access framework.

2011-12-05 Thread Eric Lentz
How about an object factory?

Interface - UserAuth
Implementation - LdapAuth implements UserAuth
Implementation - SqlAuth implements UserAuth

Factory (pseudo code):
if(ldap) {
return(new LdapAuth);
}
else if(sql) {
reutrn(new SqlAuth);
}
etc.

More pseudo code (this is inside your DAO):
UserAuth auth = Factory.getInstance(somecriteria);
auth.authenticate();




From:   Balwinder balwinder@gmail.com
To: Struts Users Mailing List user@struts.apache.org
Date:   12/05/2011 12:13 PM
Subject:Re: [OT] Searching for data access framework.



Hi Wes,

What I need is something like, if I want to access data from a database, 
i can use SQL, but if i change the source to LDAP then the access 
mechanism will change from SQL to LDAP specifics, now if the same data 
goes to flat file than again my mechanism will change, so all I need is 
some framework that if when source is changed its access mechanism 
should remain same. Hope this explains what I am looking for.

Regards,
Balwinder Kumar

On 12/5/2011 10:35 PM, Wes Wannemacher wrote:
 I am not sure if I understand your question correctly, but the first
 thing that comes to mind -

 
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html


 I would say to combine a disciplined approach of separation with a
 domain model layer, a business logic (transactional) layer and then
 IoC with Spring...

 If you were looking for more detail than that, we'll need some more
 details on your problem.

 -Wes

 On Mon, Dec 5, 2011 at 12:02 PM, Balwinderbalwinder@gmail.com 
wrote:
 Hi All,

 Can anyone suggest me a framework that can abstract the data call and 
its
 source, if there exists any? Example if I want to authenticate a user 
then
 my query shall not depend upon the data source, it could be any LDAP 
server,
 database or any file in a file system or anything else.

 Thanks in advance.

 Regards,
 Balwinder Kumar

 -
 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: Implementation of Struts 2.x with Struts 1.1

2011-12-02 Thread Eric Lentz
 1) Is it technically possible?
Yes

 2) If yes, what are the changes needs to be done for this regard?
Add the Struts 2 jars and add a filter to web.xml for .action like you 
would do for a stand-alone Struts 2 web app.

 3) Is there any documentation available explaining such implementation 
or related to this?
Just create Struts 2 pages for the new pages you want to create. Same as 
any Struts 2 web app.


Re: Right way for exception handling

2011-11-18 Thread Eric Lentz
Make sure that devMode is false. The behavior is a bit different if in 
devMode.

Re: Right way for exception handling

2011-11-11 Thread Eric Lentz
 1) Why do not struts passes exception to container by default? Could I 
configure it to do so?

I don't have time to answer all of your questions well, but you may want 
to look here:
http://struts.apache.org/2.2.1/docs/httpheader-result.html

That result type will permit the sending of any code you want. That could 
be the basis for a global result? I'm not sure if that answers one of your 
questions or not? I'm also not sure I'd purposefully send a 500 status 
code if I had the choice, but I guess that's up to you. The browser 
typically gives back a pretty ugly page for such a return status, IMO.



Re: adding style for the message in properties file.

2011-10-20 Thread Eric Lentz
 Is there any other alternative way for this

Break the message up?

If your message is My device color is div style=font-weight: 
boldRED/div. then write something like this:

s:text  name=device.preamblenbsp;div style=font-weight: bold
s:text  name=device.red/div.

where your properties file contains:
device.preamble=My device color is
device.red=RED



Re: Struts2 Memory Management

2011-10-19 Thread Eric Lentz
 any current framework can easily handle such a request

I agree. Maybe it would be helpful for the OP to let us in on what other 
framework is being considered by way of comparison so the OP can tap into 
the wealth of knowledge on this forum for real arguments to take back to 
the opposition. Also, is this 1000 objects a real use case or a 
red-herring that someone in a meeting threw out because they had some kind 
of bend away from Struts (OP's statement: assume the above is a 
requirement for now)? I'd suggest focusing on real use cases if this 1000 
example isn't one.

Like Eric points out, depending on the size of the objects, 1000 isn't 
really that much anyway. How are records being read from the DB? For 
example, using Hibernate? If so, you may want to check on your 
PersistenceContext and see how many objects are being stored there (and 
GC'd and possibly dirty checked when the session closes). 

Re: Two Docs from One Link/Action

2011-09-16 Thread Eric Lentz
Could you form your e-mail into a question? What are you trying to 
accomplish? Do you want the user to be able to download two documents at 
the same time? Do you want links to the documents? What didn't work?



From:
Nick Broadhurst hou1...@gmail.com
To:
Struts Users Mailing List user@struts.apache.org
Date:
09/16/2011 12:19 PM
Subject:
Two Docs from One Link/Action



Hi folks,

Trying to generate an additional document from a link/action that already
generates one. Here is my config:

code

action name=MedRequest class=action.WordAction
method=MedicalRecordsRequest

result name=success type=stream

param name=contentTypeapplication/msword/param

param name=inputNameinputStream/param

param
name=contentDispositionfilename=Med-Rec-Request.rtf/param

param name=bufferSize1024/param

/result

/action

/code

Grasped at a couple of straws with multiple param sets and  results but
nothing worked. I need to use result type redirect (for second doc) and
stream at same time it seems.

Thanks,

Nick




Re: Does jQuery work with Struts 1.3.8 custom tag?

2011-08-16 Thread Eric Lentz
 I have following code with drop-list name agencyName. But 
event.change() attached to this object never called.

Make sure that the rendered form is actually creating a HTML object with 
an ID of agencyName. That's usually the problem that I encounter - using 
the wrong name. Also, make sure that your script is actually being loaded. 
Firebug would be a good way to check that. That's another common issue 
(for me anyway). jQuery is independent of any server-side framework, so it 
definitely works with S1. 

Re: Does jQuery work with Struts 1.3.8 custom tag?

2011-08-16 Thread Eric Lentz
 There is no error at console but can run the script in console itself.
 Any suggestion?

Are you saying that you can verify that the script is executing? For 
example, if you alert, breakpoint or print to console before the 
installation of the change event, do you get the expected feedback from 
the script?

Re: Does jQuery work with Struts 1.3.8 custom tag?

2011-08-16 Thread Eric Lentz
 Yes script runs fine.

I would suggest making it as simple as possible. For example, take your 
rendered form and make a html file out it and take your script and the 
jQuery framework and place them all on a file system and attempt to get 
that working (comment the ajax part out). If that works, then start laying 
in complexity until it breaks and then you'll know where the problem is.


Session in Interceptors

2011-07-27 Thread Eric Lentz
In an interceptor I have a need to store a value in the session. I can see 
a session map that I find in the invocation's object graph that is 
available in the interceptor, but storing back to the map has no effect. 
Is there a Struts 2 way to get/set the session within an interceptor or 
do I just do something like this?
HttpServletRequest request = (HttpServletRequest) 
context.get(StrutsStatics.HTTP_REQUEST);
HttpSession session = request.getSession(true);
//set session as needed


Conditional fire on validation()

2011-07-18 Thread Eric Lentz
I'm using the wildcard method in my configuration

action name=foo-* class=FooAction method={1}
  result name=successpages/foo.jsp/result ...

and I want validation to fire only upon the call to the method that 
performs the save/update. No problem with the XML file as the name takes 
care of that (e.g., assuming save is the method name: 
FooAction-foo-save-validation.xml).

What about when I use the validate() method? Is there a 
standard/convention for that? I did the following, but I'm wondering if 
that is the best way.

String invokingMethod = 
ActionContext.getContext().getActionInvocation().getProxy().getMethod();
if (invokingMethod.equals(save)) {
  // Do validation
}

That solution adds more framework into my action class which I'm not wild 
about, but I already have interfaces and I'm extending ActionSupport, so 
adding one more thing... okay I guess?

I realize I could validate inside my save method, but again, I'm 
wondering what the /best/ approach is (i.e., standard/convention).

- Eric

Re: Conditional fire on validation()

2011-07-18 Thread Eric Lentz
 I'm not sure it's exactly what you're looking for, but IIRC there should 
be
 a convention for the validate method, such that you can call, for 
example, a
 method validateSave, expecting that it's fired contextually with the 
save
 action
 
 Maurizio Cucchiara

Oh yeah! I remember coming across that now. Post 40 with all these 
frameworks I have stuffed in my head... thanks for the reminder.


Re: struts 2.2.3 not reloading changes made to xml config

2011-07-13 Thread Eric Lentz
 Exploded war on JBoss.  The xml file is edited directly and the changes 
 are not picked up.Do you have to redeploy each time for the changes 
to 
 be picked up?

I'm on JBoss 5 and I have to redeploy as well for struts.xml changes to be 
picked up (and class changes too - yuck!)

Re: Using Display Tag library

2011-07-11 Thread Eric Lentz
 all samples of the displaytag library that I have come across ,
involve storing the entire resultset from the query in the session

Really? I use displaytag all the time through the equivalent of request 
scope. Just pass it a list in the same way you would use a Struts2 select 
list (http://struts.apache.org/2.2.1/docs/select.html).

If passing the whole list is problematic, you can also use the external 
paging/sorting option of displaytag (
http://www.displaytag.org/1.2/tut_externalSortAndPage.html).

- Eric

/ character an invalid key?

2011-07-07 Thread Eric Lentz
I'm using Struts 2.2.1.

I have a use case whereby form fields are generated dynamically and some 
of them are select lists. Since it is a database driven list of fields, 
the labels presented for the user are also used as keys for the map that 
the form posts back to. Using alternate keys is not desirable.

That's brief background to attempt at justification for what I'm doing. To 
provide a simple example, this is the equivalent to one of the select 
lists that gets created:
s:select list=#{'Interior':'Interior','Exterior':'Exterior'} 
  name='foo[Interior/Exterior]' 
  headerKey=-1 
  headerValue=Select One /

Interior/Exterior, as a key, seems to be an issue. Using that on a test 
form and a test action that has the following:

if(foo == null) {
bar = Foo is null;
}
else if(foo.containsKey(Interior/Exterior)) {
bar = foo.get(Interior/Exterior);
}
else {
bar = Not Found;
}

bar always gets assigned Foo is null.

Any ideas why the / character contained in a key would make it invalid? 
I tested using that exact key in a map and Java is fine with it. Since foo 
is null, it appears to not be passed at all. I tried various escaping 
(e.g., \/), but it still comes back null when / is in the key.

The page, action and configuration I used to test this is here: 
http://www.chopapp.com/#32ycxelq


Re: / character an invalid key?

2011-07-07 Thread Eric Lentz
 My first guess would be that OGNL is trying to evaluate it, although
 since it's a string, not sure that makes any sense.
 
 I don't know how your DB is laid out or how what sounds like ad-hoc
 structures are being created, but is a text ID really the only thing
 you have available?
 
 Dave

Well, the keys end up being stored in the DB, in another table from the 
source of the keys, as ad-hoc field names. You know at a glance the 
context of a stored value. It also makes it easy for reporting.

I can use the DB surrogate key of the source of the dynamic field, but 
then when I store the values I have a N+1 type query to get the field 
names or I have to get all of the keys and then find them in a List or Map 
object for each form field so that I have the label value to store in the 
final table. That's a lot of extra work, which is why it isn't desirable. 
Ultimately, I guess this will be what I have to do since this doesn't 
work.

Do we call this a bug? 


Re: / character an invalid key?

2011-07-07 Thread Eric Lentz
 Do we call this a bug?

Probably, but I don't if it's an S2 or OGNL issue.

Dave

com.opensymphony.xwork2.interceptor.ParametersInterceptor

private String acceptedParamNames = [a-zA-Z0-9\\.\\]\\[\\(\\)_'\\s]+;
private Pattern acceptedPattern = Pattern.compile(acceptedParamNames);
...

protected boolean acceptableName(String name) {
if (isAccepted(name)  !isExcluded(name)) {
return true;
}
return false;
}
protected boolean isAccepted(String paramName) {
if (!this.acceptParams.isEmpty()) {
for (Pattern pattern : acceptParams) {
Matcher matcher = pattern.matcher(paramName);
if (matcher.matches()) {
return true;
}
}
return false;
} else
return acceptedPattern.matcher(paramName).matches();
}

Using the sample app. the debugger lands on return false in 
acceptableName and never makes it to isExcluded, so isAccepted appears to 
be where it gets stopped (returns false). That must be on account of what 
is considered acceptedParamNames. 

Re: / character an invalid key?

2011-07-07 Thread Eric Lentz
 Do we call this a bug?

Probably, but I don't if it's an S2 or OGNL issue.

Dave

Per my previous post, it appears to be coming from the 
com.opensymphony.xwork2 package. This is supported through Apache now? Do 
we post this to S2's JIRA?

Re: / character an invalid key?

2011-07-07 Thread Eric Lentz
 Oh, can't you just set the parameter then?

 Dave

Um, I don't know. What do you mean? I thought that's what I did when I 
specified name='foo[Interior/Exterior]'


Re: / character an invalid key?

2011-07-07 Thread Eric Lentz
 Um, I don't know. What do you mean? I thought that's what I did when I
 specified name='foo[Interior/Exterior]'

interceptor-ref name=params/
param name=paramNames../param
/interceptor-ref


Regards
-- 
Łukasz


Do you mean acceptedParamNames? (
http://struts.apache.org/2.2.1/struts2-core/apidocs/com/opensymphony/xwork2/interceptor/ParametersInterceptor.html
)
That seems fragile for my use case because the dynamic fields can be 
updated in the database and then not updated in the struts.xml and then 
suddenly the app. breaks. I appreciate the suggestion though as a possible 
work-around.

Too bad that acceptedPattern doesn't have a setter, although I don't know 
if adding a / would break something else. Perhaps that's why it doesn't 
have a setter.


Re: / character an invalid key?

2011-07-07 Thread Eric Lentz
 IMO coupling field labels to semantic constructs is a Bad Idea

You make good points as usual. This particular app. is poised to become 
international, so perhaps a different approach has come of age? I'm forced 
in that direction anyway. As with most companies I've worked at (I'm 
contracting here), there are areas of evolution needed within the 
application on account of prior decisions. This particular use case isn't 
exactly well detailed in patterns (at least that I'm aware of), so I can 
give some grace on those decisions. Thanks for the help!

- Eric

Re: Linking to another application

2011-06-24 Thread Eric Lentz
 Dave's probably right about a missing abstraction.

Dave does tend to be right, but here's another idea entirely. Accept the 
deployment of the whole application and configure the application as a 
cluster, if possible. The cluster could even be on the same machine, so 
you don't necessarily need additional hardware, but it would permit 
bringing the application down for a deployment without resulting in 
downtime, which is the assumed aversion to the deployments, right? It adds 
complexity to the deployments (especially if DB changes) and you have to 
spend the time setting up the cluster, and testing failover without losing 
sessions (turn off new requests to a node and let the current requests 
complete before shutting down), but it would greatly ease application 
design, from what I can tell and that is where your big time sink *may* be 
over the life of the application (my lack of knowledge of your environment 
notwithstanding).

In my experience, it isn't atypical for the design that you come up with 
to be repeated if it seems to work. If you (eventually, this could be 
precedence setting) have lots of little apps communicating back to the 
main app, when the changes are more easily, and perhaps appropriately, 
completed in the main app, then you end up with a messy bunch of apps to 
manage and lots of plumbing code to maintain. Now you end up with 
configuration management (different revisions) both in the apps and the 
communication channel.

- Eric

Re: jsp caching problem

2011-06-13 Thread Eric Lentz
That's a JSP question, not Struts. Did you try Google?

http://lmgtfy.com/?q=turn+off+form+autocomplete


Re: jsp caching problem

2011-06-13 Thread Eric Lentz
 More over in my jsp i m not seeing autocomplete off attribute even 
when i use normal html input type/ tag.

Everyone is telling you that it is a browser render / HTML tag issue. 
Logically, it would seem that way as well. The browser is storing the text 
that people type in the field, no? Do you believe it is being stored on 
the server? If so, where? You are dealing with JSPs and what they render 
- HTML, and then what the browser does with same. The implied feature you 
strive for is not in Struts, AFAIK.

This is how I have solved the same problem in the past (2007). I was using 
Struts 1, but that doesn't matter. I would solve it the same way if I was 
using ASP.NET or any other such framework.

http://snippets.dzone.com/posts/show/5642

Only thing is that today, I'd use jQuery:
http://docs.jquery.com/UI/Autocomplete

You've now seen links to documents that detail what to do in HTML both at 
form and field level. You've now also seen the same done from JavaScript. 
The age of the links is not relevant. That just means it is more likely to 
work with older browsers, which is a good thing. I also saw a document 
indicating that it was to be a standard in HTML 5. I don't know if it is 
or not.

Now, have you tried any of the suggestions? They should all work AFAIK.


Re: jsp caching problem

2011-06-13 Thread Eric Lentz
 Are you currently using struts2? If so then open ur jsp and type 
attribute autocomplete in textfield or form element and see if it 
supports or not.

Yes, I am using Struts 2. I did as you instructed. I do not see anything 
related to autocomplete. I'm not sure what you were aiming for in asking 
me to do that? If it was so I could see it wasn't there, I already knew 
that - that's what I've been saying. If it was because it *is* there, then 
I don't see it. Maybe its in the latest version? I'm on 2.2.1. Either way, 
you described:

 My requirement is that, it should not display previously submitted 
credit card number and passwords.
 Whenever I put the first number, my page shows all other numbers 
previously entered as a suggession.

That issue is not addressed by Struts2, again, as far as I know. In the 
words of Forest Gump, And that's all I have to say about that.

Good luck on your issue.

Re: Where's the best way to test session timeout?

2011-05-23 Thread Eric Lentz
 1) Can we test it with a struts integration test?
 2) How can we mock the time span (ie, we obviously don't want to wait 5
 minutes for the test to finish...).

Are you testing what happens when a session is no longer a session? 
Invalidate the session in your test:
http://struts.apache.org/2.2.1/docs/how-do-we-get-invalidate-the-session.html

Otherwise, you're testing your servlet container, which is pretty silly 
IMO.

If you are testing the configuration file, then parse it and look for the 
correct timeout.


What is getModel() for?

2011-05-20 Thread Eric Lentz
*Background:
In a different thread, the following was discussed:

On Thu, May 19, 2011 at 2:22 PM, Eric Lentz wrote:
 I'm curious. If you are using ModelDriven, then why do you load your 
model
 in prepare()? Why not in getModel?

That'd mean you'd need the did I already load the model? code in
getModel(), wouldn't it? Seems cleaner to use prepare, since that's
what it's for.

Dave

*Question:
So my question is this: What is getModel supposed to be used for? I 
apparently was naively thinking it was for, well... getting the model. 
Javadoc says this about the method, Gets the model to be pushed onto the 
ValueStack instead of the Action itself. That seems to indicate that 
getModel is for getting the model.

On the Model Driven Interceptor documentation page (
http://struts.apache.org/2.2.1/docs/model-driven-interceptor.html), it 
says, In the implementation of getModel, acquire an instance of a 
business object and return it. That also seems to indicate that one 
should get the model, but says nothing about the issues raised in this 
forum.

My code has addressed the did I already load the model issue, but I was 
unfamiliar with that issue from looking at any documentation on the site. 
I had to discover that on my own. Isn't that a problem that should be 
addressed in some manner (i.e., updated documentation)? Alternately, 
should these issues be somehow addressed programmatically in the 
framework?

- Eric

Re: What is getModel() for?

2011-05-20 Thread Eric Lentz
Getting is not always the same thing as instantiating and/Or 
initializing.

That's an *excellent* point! Well said. It would be great, IMO, to call 
that out in the documentation and expand on what that means. What's the 
process for doing that? 


Re: Struts2 Validation w/ModelDriven

2011-05-19 Thread Eric Lentz
 So when this error condition is met and the user redirected back to the 
INPUT form; the
 field where they had entered xyz is now the original default
 initialized value.

Can't you check the action error and not refresh the model when there is 
an error?


RE: Struts2 Validation w/ModelDriven

2011-05-19 Thread Eric Lentz
 Not that I am aware.  The paramsPrepareParamsStack to my knowledge
 handles validation at the very end; so by the time validation has
 happened; the model has already been prepared by the prepare() method.

Right, I see you said that earlier, sorry.

So, why do you want to show what they entered, especially if it is so 
wrong? It seems satisfactory to represent the previously correct response. 
Still, if you need this, you could probably make use of ParameterAware and 
store that information somewhere where it can be accessed by your error 
display mechanism? I haven't used it before though, so just a thought. It 
might be applicable?

I'm curious. If you are using ModelDriven, then why do you load your model 
in prepare()? Why not in getModel? I don't think behavior will be any 
different though since that interceptor is on the same side of the stack 
as prepare.

- Eric



From:
CRANFORD, CHRIS chris.cranf...@setech.com
To:
Struts Users Mailing List user@struts.apache.org
Date:
05/19/2011 01:16 PM
Subject:
RE: Struts2 Validation w/ModelDriven



Not that I am aware.  The paramsPrepareParamsStack to my knowledge
handles validation at the very end; so by the time validation has
happened; the model has already been prepared by the prepare() method. 

-Original Message-
From: Eric Lentz [mailto:eric.le...@sherwin.com] 
Sent: Thursday, May 19, 2011 11:58 AM
To: Struts Users Mailing List
Subject: Re: Struts2 Validation w/ModelDriven

 So when this error condition is met and the user redirected back to
the 
INPUT form; the
 field where they had entered xyz is now the original default
 initialized value.

Can't you check the action error and not refresh the model when there is

an error?


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





Re: how could i place sign # on redirectAction param?

2011-05-16 Thread Eric Lentz
 How can i resolve this problem.

It isn't a problem. Its part of the URI standard:
http://tools.ietf.org/html/rfc3986#section-2.2

# = Hexadecimal 23 in the ascii chart.

topicId%23191 is fine because it is equal to topicId#191

It will be correctly decoded when sent to the server.



Re: RedirectAction Help!

2011-05-13 Thread Eric Lentz
 I'll take any suggestions to get this working. 

Your code snippet lacks important details that would help me answer your 
question. Use pastebin or a like service and include a minimal running 
example and then perhaps I can help.


Re: Re: RedirectAction Help!

2011-05-13 Thread Eric Lentz
 The problem is getting from startInformation.jsp begin button to 
questions with the formid.

When you hit begin from startInformation.jsp, you are submitting a form to 
beginQuestions which is acting on actions.survey.Listing. 

startInformation.jsp has a hidden field of form_id:
input type='hidden' name=form_id value='s:property 
value=selectedForm.id /' /

Listing has a field called yourForm

form_id and yourForm do not match.

Could this be your problem?

- Eric

Re: how to use ajax displaytag?

2011-05-10 Thread Eric Lentz
 I have one display-tag in my jsp page. I got the contents of the
 display tag through ajax response.

 I need to set the display tag from that response using jquery. Please 
any
 one help me in this.

That's not a Struts question.

Ask your question on stackoverflow.com with a jquery and displaytag 
tags on the question and I'll answer it.


Re: Integrating Struts 1.1 with JSF 2.0 Facelets

2011-05-03 Thread Eric Lentz
 By clicking the link will display respective page that was developed 
with JSF Facelets technology.
 I am facing problem in integrating struts with JSF.

 Could anyone let me know step by step procedure for integrating Struts 
1.1
 with JSF 2.0?

You don't say what your problem is.

As far as running a page with a different technology, which I should think 
is out of scope for this forum, an anchor tag should be sufficient. Just 
link to the other page. You just need to make sure that your web.xml is 
configured correctly for both technologies and that their respective URLs 
allow the servlet container to choose the correct software stack upon 
seeing the URL. For example, I am running Struts1 and Struts2 together. 
One is .do and one is .action, respectively. In the web.xml the one stack 
is called or the other. I've actually made it a tad more complex than 
that, but that's the general idea.

Re: Struts2 validation on List of String data

2011-05-02 Thread Eric Lentz
 String[]  names;
// OR

ArrayList names;
}

i want to validate RequiredStringValidator  validator on these names. 

I don't think the standard validations deal with arrays. Probably your 
best bet is to override validate() and validate on your own. See:

http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/Validateable.html
http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ValidationAware.html
http://struts.apache.org/2.1.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html
 
(which implements those interfaces)



Re: Field Name Collision?

2011-04-27 Thread Eric Lentz
 I don't use ModelDriven myself, but as I understand it, it places the 
Model
 Object at the top of the Value Stack, which would make userid be a 
reference
 to an attribute in the Model Object, not in the Action.  When you use
 user.userid, it's because it's trying to find the user attribute in the
 Model Object (on the top of the Value Stack), which fails so it goes a 
step
 down the stack to the Action, where it finds a user attribute to use.
 
 So, it appears Struts is functioning exactly as designed.
   (*Chris*)

Thanks for the explanation.

Are these correct statements about how Struts and ModelDriven works?

- Struts instantiates the User object (in my case) by default.
- ModelDriven places the object I choose at the top of the stack.
- Because my object is at the top of the stack, it gets selected instead 
of the object that Struts creates by default.


- Eric

Re: Field Name Collision?

2011-04-27 Thread Eric Lentz
 - Struts instantiates the User object (in my case) by default.
 - ModelDriven places the object I choose at the top of the stack.
 - Because my object is at the top of the stack, it gets selected instead 

 of the object that Struts creates by default.

I think I answered my own questions here stepping though the code. I don't 
think Struts is instantiating unless it needs to. Thanks for the answers. 
I think I see how this is all working now. I'm not sure how I feel about 
it, but at least I understand.

- Eric

Re: ModelDriven Entity Update

2011-04-26 Thread Eric Lentz
My solution looks like this:

public Foo getModel() {
foo = (Foo) session.get(Foo);
if (foo == null) {
foo = new Foo();
session.put(Foo, foo);
}
return (foo);
}

Then, someone selects a particular record in the form and I populate:
foo = facade.findById(fromForm.getId());
session.put(Foo, foo);

Now, when I do the save, the getModel set foo up so that when I call the 
save method, I have a Hibernate proxy enabled object that Hibernate knows 
that it needs to update versus adding a new record. I just have to rejoin 
it to the session.

If it was a new record, then the getModel gives me an instantiated Foo (or 
pull from DI, such as Spring) and save causes Hibernate to add a row.

Is this best practice? I don't know, but this is what I do. I suspect that 
there is a better (more Struts standard) place to put the object instead 
of the session?

- Eric



From:
CRANFORD, CHRIS chris.cranf...@setech.com
To:
Struts Users Mailing List user@struts.apache.org
Date:
04/25/2011 11:52 PM
Subject:
ModelDriven Entity Update




In a form; I have a select box defined as:
s:select name=propertyOfModel.id list=myListOfValues listKey=id
listValue=description /

In the model I have the propertyOfModel annotated as @ManyToOne as
follows:
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name=PROPERTY_ID,nullable=true,insertable=true,updatable=t
rue)
public PropertyOfModel getPropertyOfModel() {
  // ...
}

Now the form gets submitted to a Struts2 Action which implements model
driven and uses the prepare() method to setup the entity model before
setting the values from the form by querying the service tier for the
object by ID.  The problem is that when the interceptor sets the values
on the model for propertyOfModel.id; if the original propertyOfModel
object was null; then there is no issue but if the object wasn't null
when queried from the database, then I get a transient exception because
it is as if the original object is having it's primary ID changed.

How have others worked around this?  One option I explored was for
setting propertyOfModel object by it's id; I simply set a property on
the action called propertyOfModelId and then use the ID to query the
object from its associated service and then set the object instance or
set to null if ID was null. 

Any other alternatives?

Chris


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





Field Name Collision?

2011-04-26 Thread Eric Lentz
- Struts 2.2.1
- Tomcat 6.0
- JDK 1.5.0_22
- Code example of the problem: http://pastebin.com/eyyJaBg4
- Description:
I have two fields in my action class: user and userId. The user variable 
is of type User, which also contains a userId. In both cases userId is of 
type String.

While implementing SessionAware and ModelDriven...

Happy path:
If I pass a parameter in the URL as follows:
http://localhost:8080/Context/test-list.action?user.userId=foo

Then user.userId = foo when it gets to the action.

Not-so-happy path:
If I pass a parameter in the URL as follows:
http://localhost:8080/Context/test-list.action?userId=foo

Then user.userId = foo when it gets to the action.

Note that in both cases, foo was assigned to user.userId, though I used 
different keys in the URL each time!

- Work-around:
If I change either one of the names to something that is unique to the 
other, then it works as one would expect.

Am I doing something wrong?

- Eric

Re: Recommended number of forms in one action

2011-04-19 Thread Eric Lentz
 I am asking because it seems that validation is only allowed for one
 set of properties. This indicates I should create two actions

Validation can go down to the method level and you can validate what you 
desire for that method call. Just name the .xml file (if using that 
approach) with the method name as well the class name.

I would personally allow my decision on number of classes to be driven 
based on class purpose. I try to limit classes to a finite set of 
responsibilities, usually very fine-grained, in favor or more classes. 
This provides easier reuse, unit testing, etc. When classes get to be big 
and multi-purpose, then they get confusing and ripe for refactoring.

If you feel you have a single purpose that a single class should address, 
then use the one class. If you are serving multiple purposes that aren't 
related (doesn't sound like your case), then don't worry about having just 
a couple lines in a class. It is okay to have lots of classes.

Re: Struts2/Velocity Integration

2011-04-19 Thread Eric Lentz
 I'm working on a legacy system that is built on jsp.  In one of the jsps
 I need to include a velocity template.  The template does not require
 access to any dynamic data.

Struts lets you use Velocity instead of JSPs as an option. Using JSPs 
*and* Velocity isn't an out-of-the-box type of thing, I don't believe. 
What I might consider, and there might be a better way, would be to use a 
String type field in my action, render the Velocity template within the 
action (or in a facade, helper or extended class) and assign that output 
to the String. Then, in the JSP, use a s:property  where the name of it 
is the String that you assigned the output from Velocity. That should just 
dump everything that was rendered from the template.

Make sense? Other people with better ideas?

- Eric

Re: Reading .properties From Top-Level Package

2011-04-14 Thread Eric Lentz
Before the email requirement, the information was stored in a jsp and
included where necessary using tiles.  The complexity of compiling a jsp
and returning the resulting html is simply an inadequate solution.

I would explore using Velocity. Struts will display a Velocity page or you 
can shove the output into a variable that you display from a JSP - the 
result of a Struts action. E-mail and Velocity are like peanut butter and 
jelly.

I wouldn't consider storing HTML in a properties file. That sounds messy.


Re: Select collection not found only when validation xml file is used

2011-04-13 Thread Eric Lentz
@Dave
 The page displays the list--how could you not need it?
Right, during display I need it. During *SAVE* I do not need it. During 
the save is when Struts is demanding it (incorrectly I feel).

@stanlick
 Do you by chance need a @SkipValidation on a method(s) in your action? 
How have you named your validation file? 
I have it named such that it is only used during the save. I am using 
wildcard methods and name it with the method name as well as all the other 
things I have to include. Something like: 
FooAction-fooPage-save-validation.xml. It does seem to be called only 
during the save when I satisfy the framework by always populating the 
select lists.

@Chris
I prefer to implement the validate() method and perform my own 
validations.
 What do you use?
I think I'm going to take Chris' suggestion and implement validate. I 
thought about trying annotations, but Chris makes a compelling argument. 
If the standard validations are this temperamental, then rolling my own 
seems better. Plus there's less XML syntax to remember or look up. For 
certain use cases I'd have to drop to this level anyway, so I too like the 
idea of having it all in one place.

Thanks to everyone for their suggestions and help. The only thing I'm left 
wondering is if I should log a bug with the Struts team. Something seems 
wrong here. The framework should not suddenly cause a page to start 
failing just because I add a validation XML file. If I have validation 
errors, that's another story, but if I don't, then there should be no net 
difference, right?

Re: Select collection not found only when validation xml file is used

2011-04-13 Thread Eric Lentz
 If there's a validation error, the input page will be displayed.

 If the input page is being displayed, the JSP references the list.

 If the JSP references the list, it's needed.

 If the JSP page isn't being displayed, you cannot get the error
 message your getting.

I totally agree with your analysis of the operation of a validation error 
/ input page. I don't believe that's what is happening though. I ran 
Struts in debug mode and stepped through where it was getting tripped up 
and it fails very early in the cycle, when it is reading the JSP. It gets 
to the select list and expects to find a collection and immediately the 
page fails. This is before it has anything to do with the target action 
and I believe it is before validation. It is in ListUIBean.
evaluateExtraParams:
if (list instanceof String) {
value = findValue((String) list);
...
if (value == null) {
if (throwExceptionOnNullValueAttribute) {
// will throw an exception if not found
value = findValue((list == null) ? (String) list : 
list.toString(), list,
The requested list key ' + list + ' could not be 
resolved as a collection/array/map/enumeration/iterator type.  +
Example: people or people.{name});
}

Value is null, so I get the exception.


I have sample code I downloaded on validations and I've modified it to 
simulate. I don't know if attachments come through. I'm attaching it, but 
I'll also explain it with some snippets.

The Action class:
public class RegisterAction extends ActionSupport implements Preparable {

Fields:
private User user;
private ListGender genderList;

Methods (some skipped for brevity):

public String list() {
populateGenderList();
return Action.SUCCESS;
}

private void populateGenderList() {
genderList = new ArrayListGender();
Gender gender = new Gender();
gender.setCode(M);
gender.setDescription(Male);
genderList.add(gender);
gender = new Gender();
gender.setCode(F);
gender.setDescription(Female);
genderList.add(gender);
}

public String add() throws Exception {
System.out.println(user);
return Action.SUCCESS;
}

public void prepare() throws Exception {
//populateGenderList();
}

Of course, the select list is on gender.

The mapping points to list() to display the form. It has another one to 
point to add() and the form points there.

With prepare() contents commented, I get the 
throwExceptionOnNullValueAttribute during the add(). If I uncomment, it 
works. If I take out the validation file and remove prepare(), it works.

Yes, I know that I can put populateGenderList() in prepare and remove it 
from list() - not a production app., just a demonstration. Also, I'm 
trying to avoid populating the list during add() as it is unnecessary.



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

Re: Select collection not found only when validation xml file is used

2011-04-13 Thread Eric Lentz
It's not going to execute the JSP unless there's a reason to.
Something's sending it back to the JSP. Rendering the JSP is the last
thing it does during action execution, after type conversion, after
validation. It's not going to execute the JSP that requires the list
unless there's an execution path that requires it--so there's either a
type conversion/validation error, or you explicitly send it to that
JSP before initializing the list.

I want to believe that what you are saying is true, but I cannot find 
evidence of it. I am controlling for all variables being constant with the 
only change being populating the list. If the list is populated, then 
there are no errors and no validation errors. If I don't populate the 
list, then I get the noted exception. As I said, all variables are the 
same - I submit the same field values, all the code is the same (except 
the list populating), etc. Therefore, I have to conclude that there are no 
validation errors and no conversion errors and what pages I send to at 
what time is correct. I even made the input page a copy containing a 
h1 to indicate that I'm on the error page. I never see this one (unless 
I purposely have a validation error).

Thanks for all of your effort in considering this.

Re: Select collection not found only when validation xml file is used

2011-04-13 Thread Eric Lentz
Create and post an SSCCE demonstrating the perceived issue, here or
preferably on a pastebin-like service.

I assume an SSCCE is a JIRA report for Struts2? I started one but am 
waiting to hit submit in case you have something else in mind.

Is this what you have in mind for pasttebin: http://pastebin.com/ffQYT8Bf


Re: Select collection not found only when validation xml file is used

2011-04-13 Thread Eric Lentz
And I assume the zipcode thing is just for test
purposes, since zipcodes aren't numeric

This is someone's code I downloaded from the Internet for play. The real 
application is not a SSCCE, but exhibits the same symptoms.

Re: Select collection not found only when validation xml file is used

2011-04-13 Thread Eric Lentz
I'm now buying what you're selling. I did have a misunderstanding about 
when the JSP is called relative to validation. I once was blind, but now I 
see. Thanks for clearing that up. I now see how to make the application 
work correctly.

BTW, I do know about redirectAction, and use it normally. I would argue 
that most applications use this though (maybe they do, but not in my 
experience consulting with many companies). I see a lot of them that do 
not. I think that pattern isn't well understood by many web developers. I 
try to tell everyone that will listen.

Thanks for the help. My problem appears to be solved! prepare() is my 
friend.

Re: Select collection not found only when validation xml file is used

2011-04-13 Thread Eric Lentz
 prepare method is set to execute BEFORE the params from your form are 
read and processed into your action class

So prepare() is my *dumb* friend. Thanks for the tip!

Select collection not found only when validation xml file is used

2011-04-12 Thread Eric Lentz
Struts 2.2.1
I have a page with a list:
s:select name=user.gender headerKey= headerValue=Select 
Gender
listKey=code listValue=description list=genderList 
/
and I populate genderList when I display the page.

If I add a validation file, validating anything, not even specifically the 
list, the page fails telling me that the list could not be resolved as a 
collection/array/map/enumeration/iterator type. Example: people or 
people.{name}

The failure occurs before the action is even reached. If I extend 
ActionSupport and override validate() and populate the list, then the page 
works again.

This seems like a bug.

For example, if I populate the list, display the page, and then the user 
submits the page with changes, the collection should not be required 
during the submit - only the values I'm validating (which does not include 
a drop-down list of values). This is just extra DB noise that is not 
necessary.

Are there other solutions?

Re: Select collection not found only when validation xml file is used

2011-04-12 Thread Eric Lentz
 I second Chris's suggestion to initialize the list when you need it.

Cool getting feedback from you guys.

I'm not sure if you meant it this way, but my point is that I don't *need* 
the list - or at least I shouldn't need it IMO.

As a user, I hit the submit button on a form that has a select list. The 
select list was populated during the display. During the submit, I only 
require the selected value in the select list which comes down in the 
POST.

The framework is insisting though that the list be current, but only when 
I have a validation file. Again, the page works great until I put the 
validation file in place and then the framework starts wanting to have the 
list be populated - whether I do that populating in validate() or 
prepare() - which is my current work-around, but I stress work-around.

- Eric

Re: Select collection not found only when validation xml file is used

2011-04-12 Thread Eric Lentz
 since I don't use that XML Validation stuff.

What do you use?

Re: Struts2 + spring3.05 + Quartz = IncompatibleClassChangeError

2011-04-12 Thread Eric Lentz
I'd look for class loading issues. Maybe you have a couple jars with 
quartz? Maybe an incompatible version combination?

 org.springframework.beans.factory.CannotLoadBeanClassException:
 Error loading class 
[org.springframework.scheduling.quartz.JobDetailBean]

 nested exception is java.lang.IncompatibleClassChangeError:
 class org.springframework.scheduling.quartz.JobDetailBean
 has interface org.quartz.JobDetail as super class