Re: how to avoid creating new Action class instance for every request in STRUTS2

2007-09-28 Thread Chris Pratt
You're probably right, whenever the Action is created, it's
initialized.  In struts 1, since the Actions didn't go away, any data
was retained.  This was usually the source of many, many bugs.  It's a
very rare condition when you want the data from one invocation of the
Action to carry forward to the next, especially since in a multiuser
system, it may not be the same user that hits the action twice in a
row.  So the second user would get the first users data.  In order to
help prevent these errors, the designers of Struts 2 made a conscious
decision to create the Action instances as needed.

So to emulate what you had in Struts 1, where everyone shares one pool
of data from the action, just put your list in the Application scope
(ServletContext) and retrieve it when you initialize your Action.

If you really only want this to allow each user to maintain their own
list (not like the Struts 1 implementation), you could put it in
Session scope instead.

  (*Chris*)

On 9/28/07, Jose4u <[EMAIL PROTECTED]> wrote:
>
> implementation: I have .jsp in which i have two text box and a Add button.
> whenever i enter something in the two text box and click on Add button the
> values  needs to be added to the html table which is right down the entry
> area with two text boxes. Whenver i Click on add i am calling a Action class
> where i have a colection object in which i add the two text box values to
> the collection object and on SUCCESS comming to .jsp i iterate the
> collection object and display it in the .jsp.
> Problem facing:  Whenever i call the action class and i am adding, its
> adding and displaying in the html table but the next time i add the previous
> values in the collection gets removed At a time only one object is there in
> the collection. The same implementation i did it in Struts 1 it was working
> fine, but in struts 2 its not retaining the values in the collection.Is it
> because for every call a new Action instance is created in Struts2? Is there
> any intercepto i need to use? Please provide me a solution to implement this
> functionality in struts 2
>
> Thanks in advance
> Jose
>
>
> --
> View this message in context: 
> http://www.nabble.com/how-to-avoid-creating-new-Action-class-instance-for-every-request-in-STRUTS2-tf4538022.html#a12952131
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> -
> 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]



how to avoid creating new Action class instance for every request in STRUTS2

2007-09-28 Thread Jose4u

implementation: I have .jsp in which i have two text box and a Add button.
whenever i enter something in the two text box and click on Add button the
values  needs to be added to the html table which is right down the entry
area with two text boxes. Whenver i Click on add i am calling a Action class
where i have a colection object in which i add the two text box values to
the collection object and on SUCCESS comming to .jsp i iterate the
collection object and display it in the .jsp.
Problem facing:  Whenever i call the action class and i am adding, its
adding and displaying in the html table but the next time i add the previous
values in the collection gets removed At a time only one object is there in
the collection. The same implementation i did it in Struts 1 it was working
fine, but in struts 2 its not retaining the values in the collection.Is it
because for every call a new Action instance is created in Struts2? Is there
any intercepto i need to use? Please provide me a solution to implement this
functionality in struts 2

Thanks in advance 
Jose


-- 
View this message in context: 
http://www.nabble.com/how-to-avoid-creating-new-Action-class-instance-for-every-request-in-STRUTS2-tf4538022.html#a12952131
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Struts2 ... SecurePlugin?

2007-09-28 Thread Nuwan Chandrasoma

Hi,

you can write your own interceptor., there was posting few months back 
regarding this.


Thanks,

Nuwan

Mufaddal Khumri wrote:

Hello,

In Struts old we used to do this in struts.xml:

  
  


  


What is the struts 2 way of securing your actions? Is there a 
predefined interceptor or packaged plugin I can use? Any pointers.


Thanks,
Mufaddal.



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



[S2.1] smarturls

2007-09-28 Thread Piero Sartini
Should smarturls 2.0.18 work with struts 2.1?

I get the following error:

Caused by: Unable to load bean: 
type:org.texturemedia.smarturls.ResultMapBuilder 
class:org.texturemedia.smarturls.DefaultResultMapBuilder - bean - 
jar:file:/home/ps/devel/projects/cfmc/target/cfmc/WEB-INF/lib/smarturls-2.0.18.jar!/struts-plugin.xml:15:120
at 
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:215)
at 
org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:101)
at 
com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:150)
at 
com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:53)
... 28 more
Caused by: java.lang.NoClassDefFoundError: 
net/java/lang/AbstractClassLoaderResolver$Test
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
at java.lang.Class.getDeclaredConstructors(Class.java:1836)
at 
com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:205)
... 31 more

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



Re: [S2] ScopedModelDriven issues [newbie]

2007-09-28 Thread ghodgins

Does anyone have a working example using the scopedModelDriven interceptor to
work for a session bean?

I've tried with the following:

1. define interceptor in struts.xml
...

  
session
myForm
model.MyFormBean
  

...

2. define interceptor-ref for action(s) in struts.xml

  
  ...



3. Action class extends ScopedModelDriven

public class MyAction extends ActionSupport implements
ScopedModelDriven {
...
private String scopeKey;
private MyFormBean model;
...
public String getScopeKey() {
return scopeKey;
}

public void setScopeKey(String key) {
scopeKey = key;
}

public void setModel(MyFormBean model) {
this.model = model; 
}

public MyFormBean getModel() {
return model;
}
}

4. attempt to populate a property of MyFormBean via JSP form:


  
  


With this setup, the model is persisted in the session, however, none of my
properties are populated or preserved in subsequent actions/screens.

I'm sure I'm missing something trivial or completely misunderstanding
something but any help is appreciated.

Thanks,
Grant



Tracy12 wrote:
> 
> Hi,
> 
> Has any one successfull getting ScopedModelDriven with
> session scoped form beans,
> 
> I tried several times and it failed, the values only
> remains for request scope, it get reset each time.
> 
> Is this a bug.
> 
> Plese let us know how to proceed.
> 
> Thanks
> 
> 
>  
> 
> Don't pick lemons.
> See all the new 2007 cars at Yahoo! Autos.
> http://autos.yahoo.com/new_cars.html 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/ScopedModelDriven-issues-tf3776022.html#a12950248
Sent from the Struts - User mailing list archive at Nabble.com.


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



complex tag nesting?

2007-09-28 Thread Dale Newfield
I'm pretty sure I remember someone asking this question before, but I 
was unable to find it either in my archives or in nabble...


I basically want "includeParams" for a specific parameter, and I thought 
I could do it just by conditionally including the parameter like so:




It doesn't work.

I guess I can always include the param and just change the value based 
on a condition:




   '>

but I wanted to ask if there's any sensible way to make the first 
solution work?  I understand that the s:if tag is conditionally allowing 
the body to be added to the output, which is different from 
conditionally deciding whether or not to execute the body, and I 
understand that it's likely the s:url tag understands s:param children 
but not s:if children...
...but I could see a desirable use-case where someone wants to nest an 
s:iterator inside a s:url, too, and it would be nice if these types of 
constructs could work...


-Dale

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



Re: Struts2 ... SecurePlugin?

2007-09-28 Thread Brian Trzupek
In your struts.xml for the action mapping add the roles interceptor  
as following.








method="list">

/email/listemail.jsp


name="allowedRoles">Administrator,Role2,Role3,Role4



..



Then use the regular web.xml security settings and define the roles  
there and (if tomcat is used) in the tomcat-users.xml file.


brian-


On Sep 28, 2007, at 12:13 PM, Mufaddal Khumri wrote:


Hello,

In Struts old we used to do this in struts.xml:

  
  


  


What is the struts 2 way of securing your actions? Is there a  
predefined interceptor or packaged plugin I can use? Any pointers.


Thanks,
Mufaddal.



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



Re: OGNL in JSP

2007-09-28 Thread stanlick
Yes, but how does solve this problem?

On 9/28/07, Zarar Siddiqi <[EMAIL PROTECTED]> wrote:
>
> Did you know you have all the variables declared in this class as
> public static final at your disposal:
>
>
> http://svn.apache.org/viewvc/struts/struts2/tags/STRUTS_2_0_9/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java?revision=558805&view=markup
>
> They include "stack"and "ognl".
>
> Zarar
>
> On 9/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > Hell, I give up!  Can someone show me how to fetch the action context
> name
> > off the value stack from inside a jsp?  This works fine from an action
> but
> > doesn't quite follow the java beans convention!
> >
> > invocation.getStack().findString("
> com.opensymphony.xwork2.ActionContext.name
> > ")
> >
> > --
> > Scott
> > [EMAIL PROTECTED]
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Scott
[EMAIL PROTECTED]


Re: [S2] FTL Help - Access Properties

2007-09-28 Thread Dave Newton
--- "Hoying, Ken" <[EMAIL PROTECTED]> wrote:
> In JSP, I would use the text tag ( name="myKey">
> 
> How do I accomplish this in FTL?

Does <@s.text name="myKey"/> not work?

http://struts.apache.org/2.x/docs/freemarker.html
http://struts.apache.org/2.x/docs/freemarker-tags.html

d.


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



RE: [s1.35] Need help with Struts and Modules

2007-09-28 Thread Givler, Eric
Can anyone assist with this?

-Original Message-
From: Givler, Eric [mailto:[EMAIL PROTECTED]
Sent: Saturday, September 22, 2007 1:25 AM
To: user@struts.apache.org
Subject: [s1.35] Need help with Struts and Modules


Hello,
 
Let me just say that I'm struggling at times writing my first production Struts 
application.  The issue that I'm trying to wrestle with now is that part of the 
application requires security, and part of it should allow general access to 
the public.  This sounds like a case for modules (I think).  So, I separated 
the code into a main folder, and then two other folders (the secure, and 
another subsystem which is not secure).
 
If I need to have the unprotected system and the protected system SHARE some 
code as well, I'm assuming I have to keep that in the default module, since 
otherwise, a security constraint would pop up when the unauthenticated user 
tried to hit those pages.  If I'm in the authenticated module and I want to 
start a process that's defined in my default module, how would I do that?
 
That is, would it be as simple as adding a link to my JSP in my auth'd app 
pointing back to the unauth'd:
Start an application 
process
 
Now, I have two users running app entry (one auth'd and one not).  If they 
start an application and cancel it, they should return to their prospective 
"subsystem".  What am I setting up in my struts-config.xml file(s) to handle 
this, and then in my action class?  Can you be specific on this (with an 
example of code)?
 
I really appreciate any help on this one - Thanks much,
 
Eric


[S2] FTL Help - Access Properties

2007-09-28 Thread Hoying, Ken
I am new to FTL and need to access the my global properties from my
resource bundle.

In JSP, I would use the text tag (

How do I accomplish this in FTL?

Thanks in Advance!



-
***Note:The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader of
this message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient,
you are hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify the Sender
immediately by replying to the message and deleting it from your
computer. Thank you. Premier Inc.  

Re: [ot] help on generics...

2007-09-28 Thread nicolas de loof
Thanks a lot.
Nico.

2007/9/28, Engelking, Nicholas <[EMAIL PROTECTED]>:
> Unfortunately, the short answer is that you can't.
>
> The compiler will yell at you about class literals for generics because in 
> Java they are implemented using erasure. This is in contrast to C# (which is 
> where I first learned how to use generics) and annoys many people to no end. 
> It was done to maintain binary compatibility between generic and non generic 
> versions of classes and to ensure generic classes could run on JVMs that have 
> no concepts of generics. The compiler basically makes all your generic 
> methods use Object and inserts casts that are garneted to be safe by the 
> compiler.
>
> At run time the method
> Optional  opt = composite. getFeature();
> Looks like
> Optional  opt = (Optional) composite. getFeature();
> To the JVM (more or less)
>
> T.class doesn't work because class literals are resolved at runtime (even 
> though as a programmer you know what they are at compile time). Since a T 
> type is really an Object type, T.class makes no sense and doesn't give you 
> the object you want.
>
> For the method you describe, you can still avoid the casts using generics but 
> you need a parameter that takes an object representing a type, not a 
> parameter that IS a type, since type parameters aren't really method 
> parameters in the normal sense.
>
> public  T getFeature(Class clazz) {
>return aggregators.get( clazz );
> }
>
> Then you can call the method like so
>
> Optional opt = composite.getFeature( Optional.class );
>
> And there are no casts required.
>
> This comes from the fact that class objects are now parameratized to there 
> class. So for example:
>
> String.class
>
> Will return a Class object.
>
> It doesn't seem ideal but it's as close as you can get with the way Generics 
> are implemented in Java. You will have problems though if the caller of your 
> method uses type parameters instead of explicit types. For example:
>
> public class OptionWrapper {
>
>private final Composite composite;
>
>public OptionWrapper(Composite composite) {
>this.composite = composite;
>}
>
>public T getOpt() {
>//needs a class object!
>T  opt = composite. getFeature();
>return opt;
>}
> }
>
> Hope this helps.
> -Original Message-
> From: nicolas de loof [mailto:[EMAIL PROTECTED]
> Sent: September 28, 2007 4:54 AM
> To: Struts Users Mailing List
> Subject: Re: [ot] help on generics...
>
> Thanks a lot for those detailed examples !
>
> I don't want to setup a factory, but to expose internals as optional features 
> :
>
> my class is a composite, with a map of "features", where the key is
> the feature interface (
> Map)
>
> I'd like to get an optional feature using :
>
>   Optional opt = composite.getFeature( Optional.class );
>
> The generics way seems to be :
>
>   Optional  opt = composite. getFeature();
>
> How can I then get the Class object used as generics type, to get it
> from the map ?
>
>public  T getFeature()
>{
>return aggregators.get( T.class ); // Doesn't work
>}
>
>
>
> 2007/9/27, Engelking, Nicholas <[EMAIL PROTECTED]>:
> >
> > Specifically, you could use
> >
> > public  T getInstance(Class clazz)
> > throws InstantiationException, 
> > IllegalAccessException{
> > return clazz.newInstance();
> > }
> >
> > The Class object has a method newInstance() that creates an instance of 
> > a class with the default constructor. The exceptions it throws represent 
> > cases where you don't have visibility permissions for the constructor, 
> > there is no default constructor, the class is abstract, or the constructor 
> > call throws an error (which is then wrapped and rethrown). The method 
> > outlined above is just a wrapper - if you already have the class object you 
> > can just instantiate it. If you need to not use the default constructor, 
> > try something like:
> >
> > public  T getInstance(Class clazz)
> > throws IllegalArgumentException,
> > SecurityException,
> > InstantiationException,
> > IllegalAccessException,
> > InvocationTargetException,
> > NoSuchMethodException {
> > return clazz
> > .getConstructor(
> > Parameter1Type.class,
> > Parameter2Type.class)
> > .newInstance(
> > parameter1,
> > parameter2);
> > }
> >
> > The getConstructor methods takes all they types for it's parameters in 
> > declaration order. This is to resolve the method signature. In this class 
> > your class would

Re: OT, ajax form submission

2007-09-28 Thread Zarar Siddiqi
I really recommend using something like Prototype to do your Ajax
stuff.  There's no need to reinvent the wheel and introduce countless
bugs in the process, Prototype is tested for all relevant browsers and
it'll take you 10 minutes to do what you're trying to do if you use
it:

http://www.prototypejs.org/api/ajax/request
http://www.prototypejs.org/api/ajax/options

Good luck,
Zarar

On 9/27/07, Henry Park <[EMAIL PROTECTED]> wrote:
>
>
> I could not get the packaged struts2 ajax implementation to work, so I am 
> trying to go at it with plain javascript. A problem that I am having is that 
> whenever I submit the form, all of my form fields keep getting appended over 
> and over. If I click submit enough, it causes an overflow error. Can you take 
> a look at my code? Thanks.
>
> 
> function retrieveURL(url, target, submitFormFlag, nameOfFormToPost) {
>   var req = getXmlHttpRequest();
>   var method = "GET";
>   if (submitFormFlag) {
> url = url + getFormAsString(nameOfFormToPost);
> method = "POST";
>
>
>   req.setRequestHeader("Content-Type", 
> "application/x-www-form-urlencoded");
>}
>
>
>   req.onreadystatechange = function() {
>   if (req.readyState == 4) {
> if (req.status == 200) {
>   if (req.responseText.length > 0) {
> target.innerHTML = "";
> target.innerHTML = req.responseText;
>   }
> } else {
>   alert("Error encountered. Please contact support.");
> }
>   }
>   req.open(method, url, true);
>   req.send(null);
>   return false;
> }
>
> function getFormAsString(formName){
>   var x = document[formName];
>   returnString = "?1=1";
>   formElements = document[formName].elements;
>   for(var i = formElements.length-1; i >= 0; --i) {
> returnString = returnString + "&" + encodeURI(formElements[i].name) + "=" 
> + encodeURI(formElements[i].value);
>   }
>   return returnString;
> }
>
> function do_submit() {
>   retrieveURL('NameOfAction!list.action', sometarget, true, 'aform');
> }
> 
>
> 
>   
>   
>   
>   
>   
>   
> 
>
> 
>
>
> _
> Connect to the next generation of MSN Messenger
> http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline

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



Re: Mapping a jsp to an action

2007-09-28 Thread Zarar Siddiqi
Am I crazy or is Jennie using Struts 1.x and Mark just proposed a
solution for 2.x?

Jennie, your web.xml servler-mapping is overriding each other, you're
first saying you want /*/*.jsp sent to action but then you're saying
you want *.do's sent to action? I'm not too sure if that's valid.
Have you tried just using *.jsp like the following and see how far you
get?


   action
   *.jsp
   

Zarar


On 9/28/07, Jennie Moeller <[EMAIL PROTECTED]> wrote:
> Thank much Mark,
>
> I talked with a colleague and we're going to give the urlrewrite a try.
> Thanks!
> -Original Message-
> From: Mark McLaren [mailto:[EMAIL PROTECTED]
> Sent: 28 September 2007 12:02
> To: Struts Users Mailing List
> Subject: Re: Mapping a jsp to an action
>
> Hi Jennie,
>
> I am fairly new to Struts 2 but you can certainly do action wildcard
> mappings with it, such as:
>
> 
>   /{1}.jsp
> 
>
> where foo.action would map to foo.jsp.
>
> However, my guess is that what you are asking for is a little bit more
> advanced (and judging by the "*.do" you are not using Struts 2).  You
> might be better to look at using mod_rewrite on apache if you can.
> Alternatively you could create or use something like the URL rewriting
> servlet filter below.
>
> 
>
> A very simple URL mapping servlet would do the trick and look something
> like the servlet below.  I'm sure that  other other here would be able
> to improve on this with some clever one line regular expression but at
> least it gives you an idea of how to do it:
>
> public class UrlMappingServlet extends HttpServlet {
>
> public void doGet(HttpServletRequest req, HttpServletResponse
> resp) throws ServletException, IOException {
> String path=req.getServletPath();
> String queryString = req.getQueryString();
>
> // cut off the extension and leading slash
> int end = path.lastIndexOf(".jsp");
> path = path.substring(1, end);
>
> // split the path into components
> String[] pathcomponents = path.split("/");
>
> // 0 -recipes
> // 1 - number
> String number = pathcomponents[1];
> // 2 - recipe name
> String name = pathcomponents[2];
>
> String destination = "/recipeDetails.jsp"?number="
>+ number + "&name=" + name + "&" + queryString;
> RequestDispatcher rd;
> rd = req.getRequestDispatcher(destination);
> rd.forward(req, resp);
> }
>
> }
>
> Of course, best practice states you should never go directly to a JSP
> url in a Struts app.  You should always go via an action.
>
> HTH
>
> Mark
>
> On 9/28/07, Jennie Moeller <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I'm trying to map a jsp page to an action. When any jsp gets loaded
> > with the recipe path on it I want it to go to an action.
> >
> > for example:
> >
> > This uri: recipes/4735/steak-with-barbecue-sauce.jsp
> >
> > I want it to hit my
> >
> > recipeDetails action
> >
> > My struts action looks like this:
> >
> >  > type="com.pub.actions.RecipeDetailsAction"
> > name="recipeDetailsForm"
> > scope="request"
> >   validate="false">
> >
> >  > path="/WEB-INF/jsp/recipeDetails.jsp" />
> > 
> >
> >
> >
> > My web.xml looks like this:
> >
> > 
> >   action
> >   /recipes/*/*.jsp
> >  
> >
> > 
> > action
> > *.do
> > 
> >
> >
> > any ideas?
> >
> > thanks,
> > Jennie
> >
> >
> > This e-mail (and any attachments) is confidential and may contain
> > personal views which are not the views of the BBC unless specifically
> > stated.
> > If you have received it in error, please delete it from your system.
> > Do not use, copy or disclose the information in any way nor act in
> > reliance on it and notify the sender immediately. Please note that the
>
> > BBC monitors e-mails sent or received.
> > Further communication will signify your consent to this.
> >
>
>
> --
> "Paradoxically, the more time saving abstractions you are using the more
> you actually have to know." - Simon Willison
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> This e-mail (and any attachments) is confidential and may contain
> personal views which are not the views of the BBC unless specifically
> stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in
> reliance on it and notify the sender immediately. Please note that the
> BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-ma

Re: OGNL in JSP

2007-09-28 Thread Zarar Siddiqi
Did you know you have all the variables declared in this class as
public static final at your disposal:

http://svn.apache.org/viewvc/struts/struts2/tags/STRUTS_2_0_9/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java?revision=558805&view=markup

They include "stack"and "ognl".

Zarar

On 9/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hell, I give up!  Can someone show me how to fetch the action context name
> off the value stack from inside a jsp?  This works fine from an action but
> doesn't quite follow the java beans convention!
>
> invocation.getStack().findString("com.opensymphony.xwork2.ActionContext.name
> ")
>
> --
> Scott
> [EMAIL PROTECTED]
>

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



Re: style display for html:text or any control

2007-09-28 Thread Zarar Siddiqi
It's been a while since I've used Struts 1.x but did you try using
 to set a variable and them dump it in cssStyle using ${}
syntax?  If not that, you could always add the CSS class to the input
field using JavaScript.

Zarar


On 9/28/07, prem_gadgetquest <[EMAIL PROTECTED]> wrote:
>
> I have lots of control (textbox, combobox n all.) in my page..what I want
> is... when user logs in he shud be able to see contorls in editable
> format or noneditable format depending upon his role.
>
> Now in non struts ie. simple jsp page i wud hav done this way
>
> String jsEdit="";
> if(sCurrentUserRoleName.equalsIgnoreCase("Admin")
> {
> jsEdit="class='nonedit' " //nonedit is defined by me!
> }
> else
> {
>jsEdit="class='edit' "
> }
>  <%=jsEdit%>/>
>
> if same thing i wanna do it in struts then ...
>
> /> //yes
> incase of struts i m using styleClass and not class attribute of the
> html:text field
>  above snippet flashes error mark ..saying unterminated html:text tag...m
> sure its not reg. terminating html tag...but there's some way to display
> this control with variable ...please guide me best way..
>
>
> Thanks.:working:
> --
> View this message in context: 
> http://www.nabble.com/style-display-for-html%3Atext-or-any-control-tf4535191.html#a12942693
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> -
> 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: [ot] help on generics...

2007-09-28 Thread Engelking, Nicholas
Unfortunately, the short answer is that you can't.

The compiler will yell at you about class literals for generics because in Java 
they are implemented using erasure. This is in contrast to C# (which is where I 
first learned how to use generics) and annoys many people to no end. It was 
done to maintain binary compatibility between generic and non generic versions 
of classes and to ensure generic classes could run on JVMs that have no 
concepts of generics. The compiler basically makes all your generic methods use 
Object and inserts casts that are garneted to be safe by the compiler.

At run time the method
Optional  opt = composite. getFeature();
Looks like
Optional  opt = (Optional) composite. getFeature();
To the JVM (more or less)

T.class doesn't work because class literals are resolved at runtime (even 
though as a programmer you know what they are at compile time). Since a T type 
is really an Object type, T.class makes no sense and doesn't give you the 
object you want.

For the method you describe, you can still avoid the casts using generics but 
you need a parameter that takes an object representing a type, not a parameter 
that IS a type, since type parameters aren't really method parameters in the 
normal sense.

public  T getFeature(Class clazz) {
return aggregators.get( clazz );
}

Then you can call the method like so

Optional opt = composite.getFeature( Optional.class );

And there are no casts required.

This comes from the fact that class objects are now parameratized to there 
class. So for example:

String.class

Will return a Class object.

It doesn't seem ideal but it's as close as you can get with the way Generics 
are implemented in Java. You will have problems though if the caller of your 
method uses type parameters instead of explicit types. For example:

public class OptionWrapper {

private final Composite composite;

public OptionWrapper(Composite composite) {
this.composite = composite;
}

public T getOpt() {
//needs a class object!
T  opt = composite. getFeature();
return opt;
}
}

Hope this helps.
-Original Message-
From: nicolas de loof [mailto:[EMAIL PROTECTED]
Sent: September 28, 2007 4:54 AM
To: Struts Users Mailing List
Subject: Re: [ot] help on generics...

Thanks a lot for those detailed examples !

I don't want to setup a factory, but to expose internals as optional features :

my class is a composite, with a map of "features", where the key is
the feature interface (
Map)

I'd like to get an optional feature using :

   Optional opt = composite.getFeature( Optional.class );

The generics way seems to be :

   Optional  opt = composite. getFeature();

How can I then get the Class object used as generics type, to get it
from the map ?

public  T getFeature()
{
return aggregators.get( T.class ); // Doesn't work
}



2007/9/27, Engelking, Nicholas <[EMAIL PROTECTED]>:
>
> Specifically, you could use
>
> public  T getInstance(Class clazz)
> throws InstantiationException, IllegalAccessException{
> return clazz.newInstance();
> }
>
> The Class object has a method newInstance() that creates an instance of a 
> class with the default constructor. The exceptions it throws represent cases 
> where you don't have visibility permissions for the constructor, there is no 
> default constructor, the class is abstract, or the constructor call throws an 
> error (which is then wrapped and rethrown). The method outlined above is just 
> a wrapper - if you already have the class object you can just instantiate it. 
> If you need to not use the default constructor, try something like:
>
> public  T getInstance(Class clazz)
> throws IllegalArgumentException,
> SecurityException,
> InstantiationException,
> IllegalAccessException,
> InvocationTargetException,
> NoSuchMethodException {
> return clazz
> .getConstructor(
> Parameter1Type.class,
> Parameter2Type.class)
> .newInstance(
> parameter1,
> parameter2);
> }
>
> The getConstructor methods takes all they types for it's parameters in 
> declaration order. This is to resolve the method signature. In this class 
> your class would have a constructor:
>
> MyClass(Parameter1Type parameter1, Parameter2Type parameter2){
> // constructor stuff here
> }
>
> The newInstance method takes the actual parameters to pass to the 
> constructor. In this example, they are parameter1 (which is a Parameter1Type) 
> 

Struts2 ... SecurePlugin?

2007-09-28 Thread Mufaddal Khumri

Hello,

In Struts old we used to do this in struts.xml:

  
  


  


What is the struts 2 way of securing your actions? Is there a  
predefined interceptor or packaged plugin I can use? Any pointers.


Thanks,
Mufaddal.

Re: Struts Tag Question

2007-09-28 Thread Cory D. Wiles
This is how I do it:
/* drugClassPropsSrv is my map */

  

  
  

  
  

  

  



On 9/28/07, Marco Carnevale <[EMAIL PROTECTED]> wrote:
>
> I have a java.util.Map in my action (value stack) and I simply want to
> print
> it's contents
> in an HTML table in my JSP showing the key value pairs. However, I am
> having
> an issue figuring out the proper syntax.
>
> My initial approach is to iterate over the Maps keys and then during each
> iteration, call the maps get() method passing the key to it which is not
> working.  Could someone
> who has done this before show me the struts tag syntax that would
> accomplish
> this?
>
> Thanks.
>Marco
>


Re: autocompleter

2007-09-28 Thread Musachy Barroso
This was just fixed on trunk, see WW-2220. There will be a "keyValue"
attribute to set the initial value of the key. The "key" attribute is
something else, not related to the autocompleter's "key"

musachy

On 9/28/07, Giovanni Azua <[EMAIL PROTECTED]> wrote:
> Hi Meissa,
>
> Yep it is possible ... assuming you provide:
>
> 
>
> then include in the rendering Action associated to this JSP the
> following two bean property getters:
>
> // will provide the default display value that the user sees
> public String
>  getSomeProperty()
> {
> // ...
> }
>
> // will provide the key corresponding to the default value the
> // user sees
> public String
>  getSomePropertyKey()
> {
> // ...
> }
>
> Any other way to specify initial values e.g. using the autocompleter
> attributes  "key" and "value" will not work (because of some bug) the
> key will not be posted to the processing action. The only way to have it
> working is NOT to provide these attributes and use the getters from the
> page display rendering action.
>
> i.e. avoid doing this:
>
> 
>
> HTH,
> regards,
> Giovanni
>
> [EMAIL PROTECTED] wrote:
> > I would like set an initial value and key to the autocompleter with one of
> > the list elements.
> > can someone tells if it's possible.
> > Thanks.
> > Meissa
> >
> >
> >
> >
> >
> > L'integrite de ce message n'etant pas assuree sur internet, Natixis ne peut 
> > etre tenu responsable de son contenu. Toute utilisation ou diffusion non 
> > autorisee est interdite. Si vous n'etes pas destinataire de ce message, 
> > merci de le detruire et d'avertir l'expediteur.
> > Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que 
> > si necessaire
> >
> > The integrity of this message cannot be guaranteed on the Internet. Natixis 
> > can not therefore be considered responsible for the contents. Any 
> > unauthorized use or dissemination is prohibited. If you are not the 
> > intended recipient of this message, then please delete it and notify the 
> > sender.
> >
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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

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



style display for html:text or any control

2007-09-28 Thread prem_gadgetquest

I have lots of control (textbox, combobox n all.) in my page..what I want
is... when user logs in he shud be able to see contorls in editable
format or noneditable format depending upon his role.

Now in non struts ie. simple jsp page i wud hav done this way

String jsEdit="";
if(sCurrentUserRoleName.equalsIgnoreCase("Admin")
{
jsEdit="class='nonedit' " //nonedit is defined by me!
}
else
{
   jsEdit="class='edit' "
}
/>

if same thing i wanna do it in struts then ...

/> //yes
incase of struts i m using styleClass and not class attribute of the
html:text field
 above snippet flashes error mark ..saying unterminated html:text tag...m
sure its not reg. terminating html tag...but there's some way to display
this control with variable ...please guide me best way..


Thanks.:working:
-- 
View this message in context: 
http://www.nabble.com/style-display-for-html%3Atext-or-any-control-tf4535191.html#a12942693
Sent from the Struts - User mailing list archive at Nabble.com.


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



RE: struts 2.1 beta

2007-09-28 Thread Wesley Wannemacher
How are you trying to download/build the beta? Maven?

What sort of problems are you having? Compile issues, deployment issues?


Did you try the nightly build? 

If you are building from SVN using Maven, this might be helpful - 

http://www.nabble.com/struts-2.1-beta-tf4509951.html#a12880737

-Wes 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: Friday, September 28, 2007 10:43 AM
> To: user@struts.apache.org
> Subject: struts 2.1 beta
> 
> 
> I'm trying to download and build a beta release.
> I have lot of problems about that.
> Maybe someone has tried successfully. If so, can someone put 
> it somewhere so that people (like me) can share it.
> 
> Do we still have no date about a beta version upon 2.1 We 
> have serious performance problems with the 2.0.9 release and 
> we need to go the full of promises 2.1 version.
> 
> thank in advance.
> Meissa
> 
> 
> 

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



Re: autocompleter

2007-09-28 Thread Giovanni Azua

Hi Meissa,

Yep it is possible ... assuming you provide:



then include in the rendering Action associated to this JSP the 
following two bean property getters:


// will provide the default display value that the user sees
public String
getSomeProperty()
{
// ...
}

// will provide the key corresponding to the default value the
// user sees
public String
getSomePropertyKey()
{
// ...
}

Any other way to specify initial values e.g. using the autocompleter 
attributes  "key" and "value" will not work (because of some bug) the 
key will not be posted to the processing action. The only way to have it 
working is NOT to provide these attributes and use the getters from the 
page display rendering action.


i.e. avoid doing this:



HTH,
regards,
Giovanni

[EMAIL PROTECTED] wrote:

I would like set an initial value and key to the autocompleter with one of
the list elements.
can someone tells if it's possible.
Thanks.
Meissa





L'integrite de ce message n'etant pas assuree sur internet, Natixis ne peut 
etre tenu responsable de son contenu. Toute utilisation ou diffusion non 
autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci 
de le detruire et d'avertir l'expediteur.
Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que si 
necessaire

The integrity of this message cannot be guaranteed on the Internet. Natixis can 
not therefore be considered responsible for the contents. Any unauthorized use 
or dissemination is prohibited. If you are not the intended recipient of this 
message, then please delete it and notify the sender.
  


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



struts 2.1 beta

2007-09-28 Thread meissa . sakho

I'm trying to download and build a beta release.
I have lot of problems about that.
Maybe someone has tried successfully. If so, can someone put it somewhere 
so that people (like me)
can share it.

Do we still have no date about a beta version upon 2.1
We have serious performance problems with the 2.0.9 release and we need to 
go
the full of promises 2.1 version.

thank in advance.
Meissa





L'integrite de ce message n'etant pas assuree sur internet, Natixis ne peut 
etre tenu responsable de son contenu. Toute utilisation ou diffusion non 
autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci 
de le detruire et d'avertir l'expediteur.
Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que si 
necessaire

The integrity of this message cannot be guaranteed on the Internet. Natixis can 
not therefore be considered responsible for the contents. Any unauthorized use 
or dissemination is prohibited. If you are not the intended recipient of this 
message, then please delete it and notify the sender.
Let us mind the environment : let's print our mails only when necessary.


Struts Tag Question

2007-09-28 Thread Marco Carnevale
I have a java.util.Map in my action (value stack) and I simply want to print
it's contents
in an HTML table in my JSP showing the key value pairs. However, I am having
an issue figuring out the proper syntax.

My initial approach is to iterate over the Maps keys and then during each
iteration, call the maps get() method passing the key to it which is not
working.  Could someone
who has done this before show me the struts tag syntax that would accomplish
this?

Thanks.
   Marco


autocompleter

2007-09-28 Thread meissa . sakho

I would like set an initial value and key to the autocompleter with one of
the list elements.
can someone tells if it's possible.
Thanks.
Meissa





L'integrite de ce message n'etant pas assuree sur internet, Natixis ne peut 
etre tenu responsable de son contenu. Toute utilisation ou diffusion non 
autorisee est interdite. Si vous n'etes pas destinataire de ce message, merci 
de le detruire et d'avertir l'expediteur.
Ensemble, faisons un geste pour l'environnement : n'imprimons nos mails que si 
necessaire

The integrity of this message cannot be guaranteed on the Internet. Natixis can 
not therefore be considered responsible for the contents. Any unauthorized use 
or dissemination is prohibited. If you are not the intended recipient of this 
message, then please delete it and notify the sender.


Re: Slow Web Page, Speed Up?

2007-09-28 Thread Brian Trzupek

Martin,

Our codebase is on 2.0.8 now (i know we need to upgrade asap) and we  
need ti finalize some other work (our real jobs) before we can run  
the regression tests (selenium, junit) against 2.0.9.


We will know the answer to the 2.0.9 question by Monday is my guess.  
I will post when I have an answer to your question.


Brian-

On Sep 28, 2000, at 8:24 AM, Martin Gainty wrote:


Brian
Can you confirm this is a problem with Struts 2.0.9?
https://issues.apache.org/struts/browse/WW-2182
Thanks/
Martin--
- Original Message -
From: "Brian Trzupek" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Friday, September 28, 2007 7:48 AM
Subject: Re: Slow Web Page, Speed Up?



Good idea.

I sprinkled this in the page and slowly narrowed down the culprit.
Drum roll please...

It was the head theme=ajax tag. There is another long thread in this
list on that topic entirely ( [s2] Struts head tag KILLS (> 10s) page
load time
), but the short solution to my problem was to just remove that tag.
That page was not using Ajax anyways.

Page rendering time decreased by @3seconds after the removal of that
tag.

Thanks for the help!

Brian-


On Sep 28, 2007, at 2:17 AM, Oleg Mikheev wrote:


Brian Trzupek wrote:






Both of the above constructs should execute in no time.
I really think that there is something else that slows downs
your page load time.
You can always measure the time that your JSP page took
to render - output current time (<%=System.currentTimeMillis()%>)
at the top of page and then at the bottom.

Actually I haven't used the second construct personally :)


 
-

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]




-
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]



OGNL in JSP

2007-09-28 Thread stanlick
Hell, I give up!  Can someone show me how to fetch the action context name
off the value stack from inside a jsp?  This works fine from an action but
doesn't quite follow the java beans convention!

invocation.getStack().findString("com.opensymphony.xwork2.ActionContext.name
")

-- 
Scott
[EMAIL PROTECTED]


Re: Slow Web Page, Speed Up?

2007-09-28 Thread Martin Gainty
Brian 
Can you confirm this is a problem with Struts 2.0.9?
https://issues.apache.org/struts/browse/WW-2182
Thanks/
Martin--
- Original Message - 
From: "Brian Trzupek" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" 
Sent: Friday, September 28, 2007 7:48 AM
Subject: Re: Slow Web Page, Speed Up?


> Good idea.
> 
> I sprinkled this in the page and slowly narrowed down the culprit.  
> Drum roll please...
> 
> It was the head theme=ajax tag. There is another long thread in this  
> list on that topic entirely ( [s2] Struts head tag KILLS (> 10s) page  
> load time
> ), but the short solution to my problem was to just remove that tag.  
> That page was not using Ajax anyways.
> 
> Page rendering time decreased by @3seconds after the removal of that  
> tag.
> 
> Thanks for the help!
> 
> Brian-
> 
> 
> On Sep 28, 2007, at 2:17 AM, Oleg Mikheev wrote:
> 
> > Brian Trzupek wrote:
> >> 
> >> 
> >> 
> >
> > Both of the above constructs should execute in no time.
> > I really think that there is something else that slows downs
> > your page load time.
> > You can always measure the time that your JSP page took
> > to render - output current time (<%=System.currentTimeMillis()%>)
> > at the top of page and then at the bottom.
> >
> > Actually I haven't used the second construct personally :)
> >
> >
> > -
> > 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]
> 
> 

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



Re: Slow Web Page, Speed Up?

2007-09-28 Thread Brian Trzupek

Good idea.

I sprinkled this in the page and slowly narrowed down the culprit.  
Drum roll please...


It was the head theme=ajax tag. There is another long thread in this  
list on that topic entirely ( [s2] Struts head tag KILLS (> 10s) page  
load time
), but the short solution to my problem was to just remove that tag.  
That page was not using Ajax anyways.


Page rendering time decreased by @3seconds after the removal of that  
tag.


Thanks for the help!

Brian-


On Sep 28, 2007, at 2:17 AM, Oleg Mikheev wrote:


Brian Trzupek wrote:






Both of the above constructs should execute in no time.
I really think that there is something else that slows downs
your page load time.
You can always measure the time that your JSP page took
to render - output current time (<%=System.currentTimeMillis()%>)
at the top of page and then at the bottom.

Actually I haven't used the second construct personally :)


-
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: Breadcrumbs

2007-09-28 Thread stanlick
Thanks Brian --

I wanted it be automatic and work easily with Struts 2.  After probing and
searching, I realized there was no such animal so I wrote a plug-in.  This
was a testament to just how flexible the Struts 2 framework really is!  I
wrote a Bread Crumb interceptor with only a few lines of code and added it
to the stack.  After playing with it for awhile, I added several ways to
configure it with XML (at the interceptor level) to specify exactly how a
web site might like this feature to work.

I loved Struts 2 before and now I would marry it!

Scott


RE: Mapping a jsp to an action

2007-09-28 Thread Jennie Moeller
Thank much Mark,

I talked with a colleague and we're going to give the urlrewrite a try.
Thanks!
-Original Message-
From: Mark McLaren [mailto:[EMAIL PROTECTED] 
Sent: 28 September 2007 12:02
To: Struts Users Mailing List
Subject: Re: Mapping a jsp to an action

Hi Jennie,

I am fairly new to Struts 2 but you can certainly do action wildcard
mappings with it, such as:


  /{1}.jsp


where foo.action would map to foo.jsp.

However, my guess is that what you are asking for is a little bit more
advanced (and judging by the "*.do" you are not using Struts 2).  You
might be better to look at using mod_rewrite on apache if you can.
Alternatively you could create or use something like the URL rewriting
servlet filter below.



A very simple URL mapping servlet would do the trick and look something
like the servlet below.  I'm sure that  other other here would be able
to improve on this with some clever one line regular expression but at
least it gives you an idea of how to do it:

public class UrlMappingServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
String path=req.getServletPath();
String queryString = req.getQueryString();

// cut off the extension and leading slash
int end = path.lastIndexOf(".jsp");
path = path.substring(1, end);

// split the path into components
String[] pathcomponents = path.split("/");

// 0 -recipes
// 1 - number
String number = pathcomponents[1];
// 2 - recipe name
String name = pathcomponents[2];

String destination = "/recipeDetails.jsp"?number="
   + number + "&name=" + name + "&" + queryString;
RequestDispatcher rd;
rd = req.getRequestDispatcher(destination);
rd.forward(req, resp);
}

}

Of course, best practice states you should never go directly to a JSP
url in a Struts app.  You should always go via an action.

HTH

Mark

On 9/28/07, Jennie Moeller <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to map a jsp page to an action. When any jsp gets loaded 
> with the recipe path on it I want it to go to an action.
>
> for example:
>
> This uri: recipes/4735/steak-with-barbecue-sauce.jsp
>
> I want it to hit my
>
> recipeDetails action
>
> My struts action looks like this:
>
>  type="com.pub.actions.RecipeDetailsAction"
> name="recipeDetailsForm"
> scope="request"
>   validate="false">
>
>  path="/WEB-INF/jsp/recipeDetails.jsp" />
> 
>
>
>
> My web.xml looks like this:
>
> 
>   action
>   /recipes/*/*.jsp
>  
>
> 
> action
> *.do
> 
>
>
> any ideas?
>
> thanks,
> Jennie
>
>
> This e-mail (and any attachments) is confidential and may contain 
> personal views which are not the views of the BBC unless specifically 
> stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in 
> reliance on it and notify the sender immediately. Please note that the

> BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>


--
"Paradoxically, the more time saving abstractions you are using the more
you actually have to know." - Simon Willison

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



This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated.
If you have received it in error, please delete it from your system. 
Do not use, copy or disclose the information in any way nor act in
reliance on it and notify the sender immediately. Please note that the
BBC monitors e-mails sent or received. 
Further communication will signify your consent to this.

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



Re: Mapping a jsp to an action

2007-09-28 Thread Mark McLaren
Hi Jennie,

I am fairly new to Struts 2 but you can certainly do action wildcard
mappings with it, such as:


  /{1}.jsp


where foo.action would map to foo.jsp.

However, my guess is that what you are asking for is a little bit more
advanced (and judging by the "*.do" you are not using Struts 2).  You
might be better to look at using mod_rewrite on apache if you can.
Alternatively you could create or use something like the URL rewriting
servlet filter below.



A very simple URL mapping servlet would do the trick and look
something like the servlet below.  I'm sure that  other other here
would be able to improve on this with some clever one line regular
expression but at least it gives you an idea of how to do it:

public class UrlMappingServlet extends HttpServlet {

public void doGet(HttpServletRequest req, HttpServletResponse
resp) throws ServletException, IOException {
String path=req.getServletPath();
String queryString = req.getQueryString();

// cut off the extension and leading slash
int end = path.lastIndexOf(".jsp");
path = path.substring(1, end);

// split the path into components
String[] pathcomponents = path.split("/");

// 0 -recipes
// 1 - number
String number = pathcomponents[1];
// 2 - recipe name
String name = pathcomponents[2];

String destination = "/recipeDetails.jsp"?number="
   + number + "&name=" + name + "&" + queryString;
RequestDispatcher rd;
rd = req.getRequestDispatcher(destination);
rd.forward(req, resp);
}

}

Of course, best practice states you should never go directly to a JSP
url in a Struts app.  You should always go via an action.

HTH

Mark

On 9/28/07, Jennie Moeller <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to map a jsp page to an action. When any jsp gets loaded with
> the recipe path on it I want it to go to an action.
>
> for example:
>
> This uri: recipes/4735/steak-with-barbecue-sauce.jsp
>
> I want it to hit my
>
> recipeDetails action
>
> My struts action looks like this:
>
>  type="com.pub.actions.RecipeDetailsAction"
> name="recipeDetailsForm"
> scope="request"
>   validate="false">
>
>  path="/WEB-INF/jsp/recipeDetails.jsp" />
> 
>
>
>
> My web.xml looks like this:
>
> 
>   action
>   /recipes/*/*.jsp
>  
>
> 
> action
> *.do
> 
>
>
> any ideas?
>
> thanks,
> Jennie
>
>
> This e-mail (and any attachments) is confidential and may contain
> personal views which are not the views of the BBC unless specifically
> stated.
> If you have received it in error, please delete it from your system.
> Do not use, copy or disclose the information in any way nor act in
> reliance on it and notify the sender immediately. Please note that the
> BBC monitors e-mails sent or received.
> Further communication will signify your consent to this.
>


-- 
"Paradoxically, the more time saving abstractions you are using the
more you actually have to know." - Simon Willison

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



Mapping a jsp to an action

2007-09-28 Thread Jennie Moeller
Hi,
 
I'm trying to map a jsp page to an action. When any jsp gets loaded with
the recipe path on it I want it to go to an action.
 
for example:
 
This uri: recipes/4735/steak-with-barbecue-sauce.jsp
 
I want it to hit my
 
recipeDetails action
 
My struts action looks like this:
 

 


 
 
 
My web.xml looks like this:
 

  action
  /recipes/*/*.jsp
 
 

action
*.do

 
 
any ideas?
 
thanks,
Jennie 


This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated.
If you have received it in error, please delete it from your system. 
Do not use, copy or disclose the information in any way nor act in
reliance on it and notify the sender immediately. Please note that the
BBC monitors e-mails sent or received. 
Further communication will signify your consent to this.


Map jsp to action class

2007-09-28 Thread Jennie Moeller
Hi,
 
I'm trying to map a jsp page to an action.
 
for example:
 
This uri: recipes/4735/steak-with-barbecue-sauce.jsp
 
I want it to hit my
 
recipeDetails action
 
My struts action looks like this:


This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless specifically
stated.
If you have received it in error, please delete it from your system. 
Do not use, copy or disclose the information in any way nor act in
reliance on it and notify the sender immediately. Please note that the
BBC monitors e-mails sent or received. 
Further communication will signify your consent to this.


Re: listen/notify Topics doubt

2007-09-28 Thread Pablo Vázquez Blázquez

Thank you very much! It works!



Manu Mahajan escribió:

Hi

If you want to handle the before and after topics separately you can do
something like this. Note I am publishing a separate topic for the form
(submitForm) and then handling it using some javascript code


listenTopics="/refreshTree" executeScripts="true" 
loadingText=" "/>



...  

targets="workspaceAjaxContent" executeScripts="true"
loadingText=" " cssClass="submit">







dojo.event.topic.subscribe("/submitForm", function(data, type, e){
   if (type=="before"){
//do something before the form is submitted
   }
   if (type=="load")
   {
//do something after the form is submitted
//you can publish the refreshTree topic here
dojo.event.topic.publish("/refreshTree");
   }
   });


Now your tree will only be refreshed once... 


Manu

-Original Message-
From: Pablo Vázquez Blázquez [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 27, 2007 5:38 PM

To: Struts Users Mailing List
Subject: listen/notify Topics doubt

Hi all!

I have a simple question:

When a div tag contains the "listenTopics" attribute, the associated 
href is executed *Before and After* the action associated to the tag 
which invokes the notifyTopics??


listenTopics="/refreshTree" executeScripts="true" 
loadingText=" "/>



...  

targets="workspaceAjaxContent" executeScripts="true"
loadingText=" " cssClass="submit">






When I submit the form it invokes the action form and i have 2 threads 
invoking "refreshTreeUrl"... I would like to first invoke the action 
form, and then, notifyTopics. Is it possible??


Thanks.


-
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]


  



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



Re: [ot] help on generics...

2007-09-28 Thread nicolas de loof
Thanks a lot for those detailed examples !

I don't want to setup a factory, but to expose internals as optional features :

my class is a composite, with a map of "features", where the key is
the feature interface (
Map)

I'd like to get an optional feature using :

   Optional opt = composite.getFeature( Optional.class );

The generics way seems to be :

   Optional  opt = composite. getFeature();

How can I then get the Class object used as generics type, to get it
from the map ?

public  T getFeature()
{
return aggregators.get( T.class ); // Doesn't work
}



2007/9/27, Engelking, Nicholas <[EMAIL PROTECTED]>:
>
> Specifically, you could use
>
> public  T getInstance(Class clazz)
> throws InstantiationException, IllegalAccessException{
> return clazz.newInstance();
> }
>
> The Class object has a method newInstance() that creates an instance of a 
> class with the default constructor. The exceptions it throws represent cases 
> where you don't have visibility permissions for the constructor, there is no 
> default constructor, the class is abstract, or the constructor call throws an 
> error (which is then wrapped and rethrown). The method outlined above is just 
> a wrapper - if you already have the class object you can just instantiate it. 
> If you need to not use the default constructor, try something like:
>
> public  T getInstance(Class clazz)
> throws IllegalArgumentException,
> SecurityException,
> InstantiationException,
> IllegalAccessException,
> InvocationTargetException,
> NoSuchMethodException {
> return clazz
> .getConstructor(
> Parameter1Type.class,
> Parameter2Type.class)
> .newInstance(
> parameter1,
> parameter2);
> }
>
> The getConstructor methods takes all they types for it's parameters in 
> declaration order. This is to resolve the method signature. In this class 
> your class would have a constructor:
>
> MyClass(Parameter1Type parameter1, Parameter2Type parameter2){
> // constructor stuff here
> }
>
> The newInstance method takes the actual parameters to pass to the 
> constructor. In this example, they are parameter1 (which is a Parameter1Type) 
> and parameter2 (which is a Parameter2Type). The errors occur if the 
> constructor doesn't exist, the arguments are the wrong type, the caller 
> doesn't have visibility permissions, the class is abstract, or the 
> constructor throws an error (which is then wrapped and rethrown).
>
> You could also pass the parameters into the getInstance method and pick out 
> the constructer dynamically like so:
>
> public  T getInstance(Class clazz, Object... args)
> throws InvocationTargetException {
> T newObject = null;
> for (java.lang.reflect.Constructor c : 
>   clazz.getConstructors()) {
> // try creating objects with the passed
> // args until one works.
> try {
> newObject = c.newInstance(args);
> break;
> } catch (IllegalArgumentException e) {
> } catch (InstantiationException e) {
> } catch (IllegalAccessException e) {
> }
> }
> return newObject;
> }
>
> This method returns an instance of the class passed created with the 
> constructor parameters passed. If the constructor throws an error it is 
> wrapped in an InvocationTargetException and rethrown. If no constructor 
> matches the method returns null.
>
>
> -Original Message-
> From: Giovanni Azua [mailto:[EMAIL PROTECTED]
> Sent: September 27, 2007 11:56 AM
> To: Struts Users Mailing List
> Subject: Re: [ot] help on generics...
>
> how about:
>
> public static  T
> getInstance(Class aClass)
> {
>  // TODO:
> }
>
> regards,
> Giovanni
>
> nicolas de loof wrote:
> > Hello,
> >
> > my question is fully off topic, but Struts2 is the only java5 project I 
> > know.
> >
> > I'd like a method to return an instance of a class passed as parameter :
> >
> > public Object getInstance( Class clazz )
> >
> > I'd like to use generics to make the return type in sync with the
> > class type. Is this possible ???
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> ---

Re: OT, ajax form submission

2007-09-28 Thread Oleg Mikheev

Henry Park wrote:


I could not get the packaged struts2 ajax implementation to work, so I am 
trying to go at it with plain javascript.


I have Struts2 ajax working fine.
What was the problem?


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



Re: Slow Web Page, Speed Up?

2007-09-28 Thread Oleg Mikheev

Brian Trzupek wrote:




value="[EMAIL PROTECTED]@getRequest().isUserInRole('Administrator')}"/> 


Both of the above constructs should execute in no time.
I really think that there is something else that slows downs
your page load time.
You can always measure the time that your JSP page took
to render - output current time (<%=System.currentTimeMillis()%>)
at the top of page and then at the bottom.

Actually I haven't used the second construct personally :)


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