Struts2 URL building in action for JSON.

2010-12-18 Thread Ken McWilliams
I want s:url tag like functionality from within my action, so I can build a url with parameters so I can return it as a JSON result. So is there a method I can call from perhaps an AwareInterface that can accomplish this? - To

Struts2 URL building in action for JSOn

2010-12-18 Thread Ken McWilliams
I want s:url tag like functionality from within my action, so I can build a url with parameters so I can return it as a JSON result. So is there a method I can call from perhaps an AwareInterface that can accomplish this? - To

Re: Struts2 URL building in action for JSON.

2010-12-18 Thread Mead Lai
you can use JsonLib, following is the usage. http://json-lib.sourceforge.net/usage.html I do not really clear your requirement, if you provide a example would be better. Regards, Mead On Sat, Dec 18, 2010 at 5:58 AM, Ken McWilliams ken.mcwilli...@gmail.comwrote: build a url with parameters so

Re: Struts2 URL building in action for JSON.

2010-12-18 Thread Chris Pratt
I assume what you want to do is turn an action name into a URL. Here's what I've used before, I'm not sure if there's a better way, but this was adapted from code inside struts. You could put it in your action's super class to make it more reusable, but because of the injection required it

Re: Struts2 URL building in action for JSON.

2010-12-18 Thread Dave Newton
There's no reason it couldn't work in a helper class, though; you can define arbitrary beans etc. inside the config. Dave On Sat, Dec 18, 2010 at 3:12 PM, Chris Pratt thechrispr...@gmail.comwrote: I assume what you want to do is turn an action name into a URL. Here's what I've used before,

Re: Struts2 URL building in action for JSON.

2010-12-18 Thread Chris Pratt
How would Struts know to inject the helper class? It wouldn't be creating it, it would conceivably be created either as a singleton (static or otherwise) and those configuration and action mapping classes are critical to the functioning of the method. I'd love to find a way to move this out of

Re: Struts2 URL building in action for JSON.

2010-12-18 Thread Dave Newton
With an @Inject, the same way you can insert things like Strings or configuration values. On Sat, Dec 18, 2010 at 3:19 PM, Chris Pratt thechrispr...@gmail.comwrote: How would Struts know to inject the helper class? It wouldn't be creating it, it would conceivably be created either as a

Re: Struts2 URL building in action for JSON.

2010-12-18 Thread Chris Pratt
Struts only injects those when the container calls .inject() on the object, when is that going to happen on a singleton? This is what I had to do inside a JSP Tag Library to get it to work: /** * Process the start tag * * @return EVAL_BODY_BUFFERED */ @Override public int