Re: Struts 2.0.11.1 question

2011-03-10 Thread Harsh C
Great discussion, but just to give some background on my OT:

- Blessed Struts ver. is 2.0.11.1. This does not have the JSON plugin
which I think was included only in 2.1.7

- I have used GSON, and I was very impressed. Marshalling/UNMarchalling JSON
is literally 1 line of code if the model classes are set right. Great tool
to use if you can.

- I think I will go with the JSON implementation @ www.json.org/java , which
is not as slick, but importantly for me is blessed

- I would say that if a product is licensed esp. with a license like Apache
2 (Struts, GSON and a whole lot more), it would be easier to get something
approved. Unfortunately, its not. I repeat again, its not. Even if my
manager likes it, its not. :-D I laugh because I cry inside.

On Wed, Mar 9, 2011 at 11:55 AM, Chris Pratt thechrispr...@gmail.comwrote:

 I wouldn't have a problem with using the GSON project, it's another
 community maintained, battle tested project.  From your examples it should
 probably have a Struts Result object wrapped around it to make it easier to
 use, but that's beside the point.

 horse level=high status=on

 My problem is companies that are short sighted enough to think that
 spending
 developers time to produce libraries of code that are not directly related
 to their core business (like a medical or insurance company building a JSON
 library) is going to be a good thing for their bottom line.  It's not!
  It's
 going to add development and maintenance tasks to their projects that take
 away from developing new and better features that would enhance their core
 business proposition.

 As developers, when we are presented with a new projects we need to
 separate
 the core business aspects of the project from the purely technological
 aspects.  We then need to do a little research to find the best fitting,
 most mature tool to accomplish the technical goals and champion that as the
 way to spend more time on the business differentiating goals of the
 project.
  Once they see they can get more features in less time for less money,
 they'll come around.

 /horse type=dead reason=kicked

 On Wed, Mar 9, 2011 at 8:34 AM, Paul Zepernick 
 pzepern...@commercebenefitsgroup.com wrote:

   We are using the Google Gson project to handle converting our objects /
  maps to json.  I will have to take a look at the plugin, I was not even
  aware of its existence.
 
  http://code.google.com/p/google-gson/
 
  We put the result from Gson into an InputStream and send it back out
 using
  the stream result
 
   result name=success type=stream
   param
 name=contentTypeapplication/json/param
   param name=inputNamejsonStream/param
   param name=bufferSize1024/param
  /result
 
  Here is the line from our action that is setting up the InputStream from
  Gson.
 
  setJsonStream(new ByteArrayInputStream(new
  Gson().toJson(jsonResult).getBytes()));
 
 
  jsonResult is a Map, but could be any object or list of Objects.
 
  Paul
 
 
  -Original Message-
  From: Harsh C [mailto:hchau...@gmail.com hchau...@gmail.com]
  Sent: Wednesday, March 09, 2011 7:24 AM
  To: Struts Users Mailing List
  Subject: Re: Struts 2.0.11.1 question
 
  Thanks for the responses all. Not blessed just means that it is not in
  the
  list of s/w that we are allowed to work with.
 
  I ended up writing just a plain servlet for now to serve the JSON string
  which works well enough, except the JSON parsing part of course.
 
  HC
 
 
  On Mar 9, 2011 1:19 AM, Maurizio Cucchiara 
 maurizio.cucchi...@gmail.com
  
  wrote:
   What do you mean by not blessed?
  
   Maurizio Cucchiara
  
   Il giorno 09/mar/2011 00.24, Harsh C hchau...@gmail.com ha
 scritto:
   Hi,
  
   I don't know if this is the right list for a question regarding
 2.0.11.1,
  if
   not please let me know the right forum.
  
   I am trying to use Struts 2.0.11.1 to work on an AJAX-ified app using
  Dojo.
   Problem is, struts-json plugin is not blessed.
  
   Is there a way in which I can code an Action which returns a JSON
 string
   without using the JSON plugin?
  
   --
   *Thanks,
   Harsh*
 
  *The information contained in this transmission contains
  confidential information that is legally privileged. This information is
  intended only for the use of the individual or entity named above. The
  authorized recipient of this information is prohibited from disclosing
 this
  information to any other party unless required to do so by law or
 regulation
  and is required to destroy the information after its stated need has been
  fulfilled.*
 
  *If you are not the intended recipient, you are hereby notified that any
  disclosure, copying, distribution, or action taken in reliance on the
  contents of these documents is strictly prohibited. If you have received
  this information in error, please notify the sender immediately by return
  email and arrange for the return or destruction

Re: Struts 2.0.11.1 question

2011-03-09 Thread Harsh C
Thanks for the responses all. Not blessed just means that it is not in the
list of s/w that we are allowed to work with.

I ended up writing just a plain servlet for now to serve the JSON string
which works well enough, except the JSON parsing part of course.

HC


On Mar 9, 2011 1:19 AM, Maurizio Cucchiara maurizio.cucchi...@gmail.com
wrote:
 What do you mean by not blessed?

 Maurizio Cucchiara

 Il giorno 09/mar/2011 00.24, Harsh C hchau...@gmail.com ha scritto:
 Hi,

 I don't know if this is the right list for a question regarding 2.0.11.1,
if
 not please let me know the right forum.

 I am trying to use Struts 2.0.11.1 to work on an AJAX-ified app using
Dojo.
 Problem is, struts-json plugin is not blessed.

 Is there a way in which I can code an Action which returns a JSON string
 without using the JSON plugin?

 --
 *Thanks,
 Harsh*


Struts 2.0.11.1 question

2011-03-08 Thread Harsh C
Hi,

I don't know if this is the right list for a question regarding 2.0.11.1, if
not please let me know the right forum.

I am trying to use Struts 2.0.11.1 to work on an AJAX-ified app using Dojo.
Problem is, struts-json plugin is not blessed.

Is there a way in which I can code an Action which returns a JSON string
without using the JSON plugin?

-- 
*Thanks,
Harsh*


De-serialize JSON to Action

2011-01-31 Thread Harsh C
I have been working with the Struts 2 JSON plugin and I have got it set up
so that I can serialize my Java beans as a JSON string and pass it along to
the browser.
Is the reverse possible using the plugin? That is, if I have a JS widget
(Dojo, in this case) that spits out JSON, can I read in the JSON string and
de-serialize it to a Java bean?

I would appreciate it if someone could point me to a best-practice for doing
so.

-- 
*Thanks,
Harsh*


Re: De-serialize JSON to Action

2011-01-31 Thread Harsh C
Looks like this will work for me. Thanks!

On Mon, Jan 31, 2011 at 4:14 PM, Johannes Geppert jo...@web.de wrote:


 for a while i wrote a blog post How to parse a JSON Object when using
 multiSearch for jqGrid with Java, I think you can adopt it to your
 problem.



 http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/

 http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/

 Johannes


 Harsh C wrote:
 
  I have been working with the Struts 2 JSON plugin and I have got it set
 up
  so that I can serialize my Java beans as a JSON string and pass it along
  to
  the browser.
  Is the reverse possible using the plugin? That is, if I have a JS widget
  (Dojo, in this case) that spits out JSON, can I read in the JSON string
  and
  de-serialize it to a Java bean?
 
  I would appreciate it if someone could point me to a best-practice for
  doing
  so.
 
  --
  *Thanks,
  Harsh*
 
 


 -
 ---
 web: http://www.jgeppert.com
 twitter: http://twitter.com/jogep

 --
 View this message in context:
 http://old.nabble.com/De-serialize-JSON-to-Action-tp30810552p30810811.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




-- 
*Thanks,
Harsh*


Re: De-serialize JSON to Action

2011-01-31 Thread Harsh C
I would think probably not because at runtime, the JVM would need to know
the type of the objects in the list. But its late here, and I haven't given
it much thought.

On Mon, Jan 31, 2011 at 11:19 PM, JOSE L MARTINEZ-AVIAL jlm...@gmail.comwrote:

 Hello,
  I was wondering about how to do this, and I just saw your mail. The post
 is interesting and useful, but I was wondering if it is possible to
 automatice the conversion for beans. According to the documentation(
 http://struts.apache.org/2.2.1.1/docs/json-plugin.html) a list of beans
 will
 be mapped to a List of Maps. For example, let's say I receive the following
 JSON into my action:

 {identifier:name,
  items:[
 {
 accessLevel:NO_ACCESS,
 desc:Officers,
 name:ECO Officer,
 type:ROLE
 },{
 accessLevel:NO_ACCESS,
 desc:Publications,
 name:ECO Publications Manager,
 type:ROLE
 ],
 targetIdBox:17101}

As required by the json plugin, I would need to define a
 setIdentifier(String), setTargetIdBox(int), and a setItems(ListMap). That
 works correctly, but I would like to automatice the conversion from a Map
 to
 a bean. Is it possible?

Thanks

 Jose Luis

 2011/1/31 Harsh C hchau...@gmail.com

  Looks like this will work for me. Thanks!
 
  On Mon, Jan 31, 2011 at 4:14 PM, Johannes Geppert jo...@web.de wrote:
 
  
   for a while i wrote a blog post How to parse a JSON Object when using
   multiSearch for jqGrid with Java, I think you can adopt it to your
   problem.
  
  
  
  
 
 http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/
  
  
 
 http://www.jgeppert.com/2010/06/how-to-parse-a-json-object-when-using-multisearch-for-jqgrid-with-java/
  
   Johannes
  
  
   Harsh C wrote:
   
I have been working with the Struts 2 JSON plugin and I have got it
 set
   up
so that I can serialize my Java beans as a JSON string and pass it
  along
to
the browser.
Is the reverse possible using the plugin? That is, if I have a JS
  widget
(Dojo, in this case) that spits out JSON, can I read in the JSON
 string
and
de-serialize it to a Java bean?
   
I would appreciate it if someone could point me to a best-practice
 for
doing
so.
   
--
*Thanks,
Harsh*
   
   
  
  
   -
   ---
   web: http://www.jgeppert.com
   twitter: http://twitter.com/jogep
  
   --
   View this message in context:
  
 
 http://old.nabble.com/De-serialize-JSON-to-Action-tp30810552p30810811.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
  
  
 
 
  --
  *Thanks,
  Harsh*
 




-- 
*Thanks,
Harsh*


AJAX file upload

2010-11-30 Thread Harsh C
How can I setup a AJAX-ified file upload page using Struts 2? If there is
some integration with Dojo, it would be even better i.e. not use the OS
specific file upload button etc.

-- 
*Thanks,
Harsh*


Specify template to use for struts tag

2010-11-23 Thread Harsh C
Is there a way to specify a template to use for a struts tag, on a per tag
basis e.g.

I am trying to change the checkboxlist default LF so that it renders in a
table. This is working fine. But if I want to use the default LF also, how
do I do that.

As of now, I copied the struts provided .ftl files and messed around with
them. Can I create my own template and then specify something in e.g.
s:checkboxlist to use a different template to render the check box list?



-- 
*Thanks,
Harsh*


Re: Specify template to use for struts tag

2010-11-23 Thread Harsh C
Thanks!

Actually, I used the template attribute and it worked great. Now, I have
access to the default ftl as well as to the templates that I am creating.

On Tue, Nov 23, 2010 at 3:23 PM, Dave Newton davelnew...@gmail.com wrote:

 Use the theme attribute.

 Dave

 On Tue, Nov 23, 2010 at 2:32 PM, Harsh C hchau...@gmail.com wrote:

  Is there a way to specify a template to use for a struts tag, on a per
 tag
  basis e.g.
 
  I am trying to change the checkboxlist default LF so that it renders in
 a
  table. This is working fine. But if I want to use the default LF also,
 how
  do I do that.
 
  As of now, I copied the struts provided .ftl files and messed around with
  them. Can I create my own template and then specify something in e.g.
  s:checkboxlist to use a different template to render the check box list?
 
 
 
  --
  *Thanks,
  Harsh*
 




-- 
*Thanks,
Harsh*


Re: Struts2, convention plugin, websphere 6.1

2010-11-17 Thread Harsh C
Hi,

I have an input page which has a checkbox list in a form. Clicking submit
takes the user to a 2nd JSP.
The problem is that when I don't select a checkbox and click on submit, I
get to the output page, of course no value is displayed on the output page
though.
But if I select a checkbox and click submit, I get an error saying

No result defined for action .action.ModelHomeAction and result input
I just started with struts and don't really know why it is looking for the
result input. I would appreciate any help with this.

Relevant code is below.

input.jsp
 s:form method=post action=modelUpload
 s:checkboxlist name=selectedModel list=modelList listKey=modelId
listValue=modelName/
  s:submit/s:submit
 /s:form

output.jsp

s:property value=selectedModel/

Action
 private ArrayListModel modelList;
 private Model selectedModel = new Model();

 public ArrayListModel getModelList() {
 FrameworkHandler handler = new FrameworkHandler();
  return handler.getModels();
 }

 public void setModelList(ArrayListModel modelList) {
 this.modelList = modelList;
 }

 public Model getSelectedModel() {
 return selectedModel;
 }

 public void setSelectedModel(Model selectedModel) {
 this.selectedModel = selectedModel;
 }

 public String execute() throws Exception {
  LOG.debug(Model Home Action);
 return SUCCESS;
 }

 public String upload() throws Exception{
 return SUCCESS;
 }

struts.xml

  action name=modelHome class=.action.ModelHomeAction
method=execute
result name=success/jsp/input.jsp/result
  /action

  action name=modelUpload class=.action.ModelHomeAction
method=upload
result name=success/jsp/output.jsp/result
  /action


Re: Struts2, convention plugin, websphere 6.1

2010-11-17 Thread Harsh C
So, result input is some kind of default result that struts sends a user
to?

Is validation turned on by default, as I did not specify any validation? If
so, how can I turn it off?

Thanks,
HC

On Wed, Nov 17, 2010 at 11:39 AM, Dave Newton davelnew...@gmail.com wrote:

 Failed validation will send user back to the input result.

 Dave
  On Nov 17, 2010 2:29 PM, Harsh C hchau...@gmail.com wrote:
  Hi,
 
  I have an input page which has a checkbox list in a form. Clicking submit
  takes the user to a 2nd JSP.
  The problem is that when I don't select a checkbox and click on submit, I
  get to the output page, of course no value is displayed on the output
 page
  though.
  But if I select a checkbox and click submit, I get an error saying
 
  No result defined for action .action.ModelHomeAction and result input
  I just started with struts and don't really know why it is looking for
 the
  result input. I would appreciate any help with this.
 
  Relevant code is below.
 
  input.jsp
  s:form method=post action=modelUpload
  s:checkboxlist name=selectedModel list=modelList listKey=modelId
  listValue=modelName/
  s:submit/s:submit
  /s:form
 
  output.jsp
 
  s:property value=selectedModel/
 
  Action
  private ArrayListModel modelList;
  private Model selectedModel = new Model();
 
  public ArrayListModel getModelList() {
  FrameworkHandler handler = new FrameworkHandler();
  return handler.getModels();
  }
 
  public void setModelList(ArrayListModel modelList) {
  this.modelList = modelList;
  }
 
  public Model getSelectedModel() {
  return selectedModel;
  }
 
  public void setSelectedModel(Model selectedModel) {
  this.selectedModel = selectedModel;
  }
 
  public String execute() throws Exception {
  LOG.debug(Model Home Action);
  return SUCCESS;
  }
 
  public String upload() throws Exception{
  return SUCCESS;
  }
 
  struts.xml
 
  action name=modelHome class=.action.ModelHomeAction
  method=execute
  result name=success/jsp/input.jsp/result
  /action
 
  action name=modelUpload class=.action.ModelHomeAction
  method=upload
  result name=success/jsp/output.jsp/result
  /action




-- 
*Thanks,
Harsh*


Re: Struts2, convention plugin, websphere 6.1

2010-11-17 Thread Harsh C
I think that is probably what it was. Basically in my action, I had a list
of model objects (modelList) and a model object (selectedModel).

I changed the Model type object selectedModel to String type selectedModelId
and things work fine now.

Now my question is, if I had a checkboxlist backed by a list of Model
objects, and upon checking some models, I wanted a list of selectedModel
objects, is there a way in struts to do it?

Thanks,
HC

On Wed, Nov 17, 2010 at 11:47 AM, Dave Newton davelnew...@gmail.com wrote:

 Could also be a type conversion error.
 On Nov 17, 2010 2:46 PM, Harsh C hchau...@gmail.com wrote:
  So, result input is some kind of default result that struts sends a
 user
  to?
 
  Is validation turned on by default, as I did not specify any validation?
 If
  so, how can I turn it off?
 
  Thanks,
  HC
 
  On Wed, Nov 17, 2010 at 11:39 AM, Dave Newton davelnew...@gmail.com
 wrote:
 
  Failed validation will send user back to the input result.
 
  Dave
  On Nov 17, 2010 2:29 PM, Harsh C hchau...@gmail.com wrote:
   Hi,
  
   I have an input page which has a checkbox list in a form. Clicking
 submit
   takes the user to a 2nd JSP.
   The problem is that when I don't select a checkbox and click on
 submit,
 I
   get to the output page, of course no value is displayed on the output
  page
   though.
   But if I select a checkbox and click submit, I get an error saying
  
   No result defined for action .action.ModelHomeAction and result
 input
   I just started with struts and don't really know why it is looking for
  the
   result input. I would appreciate any help with this.
  
   Relevant code is below.
  
   input.jsp
   s:form method=post action=modelUpload
   s:checkboxlist name=selectedModel list=modelList
 listKey=modelId
   listValue=modelName/
   s:submit/s:submit
   /s:form
  
   output.jsp
  
   s:property value=selectedModel/
  
   Action
   private ArrayListModel modelList;
   private Model selectedModel = new Model();
  
   public ArrayListModel getModelList() {
   FrameworkHandler handler = new FrameworkHandler();
   return handler.getModels();
   }
  
   public void setModelList(ArrayListModel modelList) {
   this.modelList = modelList;
   }
  
   public Model getSelectedModel() {
   return selectedModel;
   }
  
   public void setSelectedModel(Model selectedModel) {
   this.selectedModel = selectedModel;
   }
  
   public String execute() throws Exception {
   LOG.debug(Model Home Action);
   return SUCCESS;
   }
  
   public String upload() throws Exception{
   return SUCCESS;
   }
  
   struts.xml
  
   action name=modelHome class=.action.ModelHomeAction
   method=execute
   result name=success/jsp/input.jsp/result
   /action
  
   action name=modelUpload class=.action.ModelHomeAction
   method=upload
   result name=success/jsp/output.jsp/result
   /action
 
 
 
 
  --
  *Thanks,
  Harsh*




-- 
*Thanks,
Harsh*


Re: Struts2, convention plugin, websphere 6.1

2010-11-17 Thread Harsh C
I am using Struts 2.2.1 and would like to get some AJAX functionality in my
app, specifically, I would like to use Dojo. The Dojo plugin was deprecated
for this release, is there some good documentation/tutorials for getting
into Struts 2.2.1 with DOJO?