Re: CodeBehind and index action?

2008-07-13 Thread Jeromy Evans

Paul Benedict wrote:

Does the CodeBehind plugin allow me to specify a default action for a
directory? So that way I can just do /dir instead of /dir/index.action? If
not, how can I do it? I want any directory to go invoke index.action

I am using Struts 2.0.11

Paul
  


No, that's a feature of the Convention plugin in 2.1.x though.

A simple alternative is to write a custom ActionMapper that extends the 
default and sets the action name to index if there was no other match 
and no extension.



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



Re: Thoughts of using explicit regexps instead of wilcards for action mappings?

2008-07-13 Thread Jeromy Evans

Karr, David wrote:

MyStuff_(add|save|load|delete), that is still more concise than having


Has anyone ever considered this?

  
I threw this together but don't use it any more:   
http://code.google.com/p/struts2urlplugin/


You can plugin a regex matcher (default) or plaintext or others.

After using it for a while I found it more effective to build custom 
action mappers instead of over-engineer an all-purpose actionmapper.


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



Re: question about submitting checkboxes

2008-07-13 Thread Jeromy Evans

Eric Hamacher wrote:

Hello:

 


I have a form on which there can, in theory, be an infinite number of
checkboxes (Users are selecting files from a tree and there is no
telling how many will be selected).  The name of each checkbox is
determined at runtime (= to the path of the file).  That being the case,
how can I set up an action to read these parameters?  Or do it need to
go back to the servlet API?

  

If you're using Struts 2, don't name your checkboxes like that.
Create an array or list property in your action and include the index in 
each checkbox name:


ListString filenames = new LinkedListString();

input type=checkbox name=filenames[0] value=filenameA
input type=checkbox name=filenames[1] value=filenameB
input type=checkbox name=filenames[2] value=filenameC


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



Struts Text Property together(s:text and s:property

2008-07-13 Thread Jishnu Viswanath

Hi all,
I would like to achieve something like this s:text name=s:
property value=someProperty / /

I know this code is not going to work; in short the name that should
come is inside a property, 

Eg:-
someProperty = my.text.label
s:property value= someProperty / gives me my.text.label

s:text name=my.text.label/ give me the value I wanted.
But how can I get both at same time?

Any one has any idea?

PS: I am using struts 2 :)


Regards,

Jishnu Viswanath


Any comments or statements made in this email are not necessarily those of 
Tavant Technologies.
The information transmitted is intended only for the person or entity to which 
it is addressed and may 
contain confidential and/or privileged material. If you have received this in 
error, please contact the 
sender and delete the material from any computer. All e-mails sent from or to 
Tavant Technologies 
may be subject to our monitoring procedures.


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



RE: question about submitting checkboxes

2008-07-13 Thread Jishnu Viswanath
Eric,
If you are using struts 2, Eric have u tried s:checkboxList ??
Syntax: s:checkboxlist list= listKey=  listValue= name=/

If its just a Boolean object ignore the key value :D


Regards,

Jishnu Viswanath

Software Engineer

*(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll

Tavant Technologies Inc.,

www.tavant.com

PEOPLE :: PASSION :: EXCELLENCE


-Original Message-
From: Jeromy Evans [mailto:[EMAIL PROTECTED] 
Sent: Sunday, July 13, 2008 1:38 PM
To: Struts Users Mailing List
Subject: Re: question about submitting checkboxes

Eric Hamacher wrote:
 Hello:

  

 I have a form on which there can, in theory, be an infinite number of
 checkboxes (Users are selecting files from a tree and there is no
 telling how many will be selected).  The name of each checkbox is
 determined at runtime (= to the path of the file).  That being the
case,
 how can I set up an action to read these parameters?  Or do it need to
 go back to the servlet API?

   
If you're using Struts 2, don't name your checkboxes like that.
Create an array or list property in your action and include the index in

each checkbox name:

ListString filenames = new LinkedListString();

input type=checkbox name=filenames[0] value=filenameA
input type=checkbox name=filenames[1] value=filenameB
input type=checkbox name=filenames[2] value=filenameC


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

Any comments or statements made in this email are not necessarily those of 
Tavant Technologies.
The information transmitted is intended only for the person or entity to which 
it is addressed and may 
contain confidential and/or privileged material. If you have received this in 
error, please contact the 
sender and delete the material from any computer. All e-mails sent from or to 
Tavant Technologies 
may be subject to our monitoring procedures.


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



Re: Struts Text Property together(s:text and s:property

2008-07-13 Thread Jeromy Evans

Jishnu Viswanath wrote:

Hi all,
I would like to achieve something like this s:text name=s:
property value=someProperty / /

  
If your action extends ActionSupport, or implements TextProvider, or a 
TextProvider is in the ValueStack, then you can call one of the various 
getText() methods to access resources.


Something like the following should work:

s:property value=getText(someProperty)/

ie. evaluate someProperty, then invoke the getText(String) method to get 
the resource with that name.




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



[S2] action mapping with merely default action

2008-07-13 Thread Pierre Thibaudeau
With Struts1, if I wished to render a JSP page without bothering with the
machinery of an action (yet going through the filters/interceptors), I would
have an action mapping as follows:

action path=/home forward=/static/home.jsp /

With Struts2, in the same situation, I would do:

action name=home class=com.opensymphony.xwork2.ActionSupport
result/static/home.jsp/result
/action

This is a case where Struts2 is a lot wordier than Struts1.  (I have to do
this about 15 times, for the site's static pages...)

Is there a shorthand version?


Referring to Properties object via OGNL?

2008-07-13 Thread Dave Belfer-Shevett
I have a situateion where I'm loading application specific settings via a 
Properties object on initialization.  I'm storing the Properties object up 
into the ApplicationMap (heck it could be in the SessionMap, I'm easy), 
but i can't seem to switch JSP behaviour based on information in the 
Properties map.


I'm wondering if this is because Properties isn't exactly a HashMap, so 
the #attr.mapname.somekey isn't working.


If I have a Properties object called 'props' in the SessionMap (or 
anywhere on the stack actually), I should be able to get to it via #attr - 
what's the proper syntax?


Java-wise, it's

Property p = new Properties;
String value = p.getProperty(somekey)

but naturally I don't want to do this in a scriptlet.

Help?

--
---..---.
Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \
blog:planet-geek.com '---.
[EMAIL PROTECTED]/ Things you'll hear if you have a Klingon on  \
---   your development team: 3) This code is a|
   |   piece of crap! You have no honor!   |
\__/


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



Re: [S2] action mapping with merely default action

2008-07-13 Thread Dave Newton
--- On Sun, 7/13/08, Pierre Thibaudeau wrote:
 [S1] action path=/home forward=/static/home.jsp /
 
 [S2] 
 action name=home class=com.opensymphony.xwork2.ActionSupport
   result/static/home.jsp/result
 /action

If you're intent on using XML configuration, leave out the class.

 action name=home
   result/static/home.jsp/result
 /action

Dave


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



Re: [S2] action mapping with merely default action

2008-07-13 Thread Dave Newton
(Whoops; wrong button.)

Depending on how your application is laid out you could also put a catch-all 
mapping at the end of your regular mappings, like so:

action name=*
  result/static/{1}.jsp/result
/action

Again, this is if you're intent on using XML configuration.

Dave

--- On Sun, 7/13/08, Pierre Thibaudeau [EMAIL PROTECTED] wrote:

 From: Pierre Thibaudeau [EMAIL PROTECTED]
 Subject: [S2] action mapping with merely default action
 To: Struts Users Mailing List user@struts.apache.org
 Date: Sunday, July 13, 2008, 4:43 PM
 With Struts1, if I wished to render a JSP page without
 bothering with the
 machinery of an action (yet going through the
 filters/interceptors), I would
 have an action mapping as follows:
 
 action path=/home
 forward=/static/home.jsp /
 
 With Struts2, in the same situation, I would do:
 
 action name=home
 class=com.opensymphony.xwork2.ActionSupport
 result/static/home.jsp/result
 /action
 
 This is a case where Struts2 is a lot wordier than Struts1.
  (I have to do
 this about 15 times, for the site's static
 pages...)
 
 Is there a shorthand version?

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



Re: [S2] action mapping with merely default action

2008-07-13 Thread Pierre Thibaudeau
Brilliant!  Thanks, Dave!

2008/7/13 Dave Newton [EMAIL PROTECTED]:

 Depending on how your application is laid out you could also put a
 catch-all mapping at the end of your regular mappings, like so:

 action name=*
  result/static/{1}.jsp/result
 /action

 Again, this is if you're intent on using XML configuration.



Re: Referring to Properties object via OGNL?

2008-07-13 Thread Gabriel Belingueres
Properties implements the Map interface, so AFAIK, it should work
accessing it as a Map.

Did you tried #attr.mapname[somekey]?

2008/7/13 Dave Belfer-Shevett [EMAIL PROTECTED]:
 I have a situateion where I'm loading application specific settings via a
 Properties object on initialization.  I'm storing the Properties object up
 into the ApplicationMap (heck it could be in the SessionMap, I'm easy), but
 i can't seem to switch JSP behaviour based on information in the Properties
 map.

 I'm wondering if this is because Properties isn't exactly a HashMap, so the
 #attr.mapname.somekey isn't working.

 If I have a Properties object called 'props' in the SessionMap (or anywhere
 on the stack actually), I should be able to get to it via #attr - what's the
 proper syntax?

 Java-wise, it's

 Property p = new Properties;
 String value = p.getProperty(somekey)

 but naturally I don't want to do this in a scriptlet.

 Help?

 --
 ---..---.
 Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \
 blog:planet-geek.com '---.
 [EMAIL PROTECTED]/ Things you'll hear if you have a Klingon on  \
 ---   your development team: 3) This code is a|
   |   piece of crap! You have no honor!   |
\__/


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



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



RE: Referring to Properties object via OGNL?

2008-07-13 Thread Dave Belfer-Shevett

On Sun, 13 Jul 2008, Martin Gainty wrote:

access it with
%
ValueStack stack = getStack();
stack.findValue(#attr.someKey);
%
http://www.docjar.com/docs/api/java/util/Stack.html

where you put the value.. HashSet,HashMap or Property is up to you..


Doesn't this violate the 'scriptlets are bad' concept?

-dbs

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



Re: Referring to Properties object via OGNL?

2008-07-13 Thread Dave Belfer-Shevett

On Sun, 13 Jul 2008, Gabriel Belingueres wrote:

Properties implements the Map interface, so AFAIK, it should work
accessing it as a Map.

Did you tried #attr.mapname[somekey]?


Yes...

I have an interceptor that does:

applicationMap = invocation.getInvocationContext().getApplication();
applicationMap.put(properties,props);
logger.debug(Props loaded:  + props.toString());

(when run, this sez:
2008-07-12 23:18:37,828 DEBUG 
com.stonekeep.congo.interceptors.DBInterceptor:138 - Props loaded: 
{preferredcid=2008}


In my JSP, I have:
Preferred cid is s:property value=#attr.properties[preferredcid]/br

Which, when rendered:
Pddreferred cid is

(with nothing after it)

The entire interceptor that is loading up the properties file and 
publishing it into the ApplicationMap is here:


http://pastebin.stonekeep.com/4949

I may be missing something painfully obvious, but... help?

-d

--
---..---.
Dave Belfer-Shevett \ KB1FWR \ JID: [EMAIL PROTECTED] \
blog:planet-geek.com '---.
[EMAIL PROTECTED]/   Windows98 Err#021 - Error Parsing Error\
---List; Please Wait For Next Error|
\__/

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



Re: [S2] action mapping with merely default action

2008-07-13 Thread Jeromy Evans



2008/7/13 Dave Newton [EMAIL PROTECTED]:

  

Again, this is if you're intent on using XML configuration.




Dave didn't mention that if you're NOT intent on using XML 
configuration, then the CodeBehind plugin was created exactly for this 
purpose.


http://struts.apache.org/2.x/docs/codebehind-plugin.html


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



Re: Referring to Properties object via OGNL?

2008-07-13 Thread Jeromy Evans

Dave Belfer-Shevett wrote:



In my JSP, I have:
Preferred cid is s:property value=#attr.properties[preferredcid]/br

Which, when rendered:
Pddreferred cid is

(with nothing after it)


This expression reads evaluate perferredcid, then get the value of 
#attr.properties[evalresult].


I expect you want. s:property value=#attr.properties['preferredcid']/

so it uses the literal string 'preferredcid' instead of evaluating it.

Please let me know if that fixes it.  OGNL doesn't provide much useful 
feedback for cases like these.







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



[S2] current URL in ValueStack?

2008-07-13 Thread Pierre Thibaudeau
(Struts 2.1.2)
In the JSP, is it possible through some OGNL expression to get hold of the
URL of the current request?  I looked through the XML output obtained
through debugging, but could not find anything.

(I know I can get hold of the action and parameters; so there might a
complicated way out...)


Re: [S2] current URL in ValueStack?

2008-07-13 Thread Jeromy Evans

Pierre Thibaudeau wrote:

(Struts 2.1.2)
In the JSP, is it possible through some OGNL expression to get hold of the
URL of the current request?  I looked through the XML output obtained
through debugging, but could not find anything.

(I know I can get hold of the action and parameters; so there might a
complicated way out...)
  


The HttpServletRequest includes the getRequestURI() method.  You can 
access that easily using EL but OGNL is a little obscure.


The request object is available in the context map in a property called 
com.opensymphony.xwork2.dispatcher.HttpServletRequest.


s:property 
value=%{#context['com.opensymphony.xwork2.dispatcher.HttpServletRequest'].requestURI}/





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



Re: [S2] current URL in ValueStack?

2008-07-13 Thread Pierre Thibaudeau
Hello Jeromy,
I thought of your OGNL solution a few minutes ago, just before reading your
post.  I had been so adamant on finding the value explicitly within the
value stack, that I had momentarily forgotten that I had access to the
HttpServletRequest object.

But your statement about EL intrigues me.  How would you do that in EL?  Is
there some value available to EL in the request context?


2008/7/14 Jeromy Evans [EMAIL PROTECTED]:

 The HttpServletRequest includes the getRequestURI() method.  You can access
 that easily using EL but OGNL is a little obscure.

 The request object is available in the context map in a property called
 com.opensymphony.xwork2.dispatcher.HttpServletRequest.

 s:property
 value=%{#context['com.opensymphony.xwork2.dispatcher.HttpServletRequest'].requestURI}/