You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ma...@ensam.eu on 2012/03/05 16:29:26 UTC

JSon, includeProperties and modelDriven

Hi,

I am trying to make an action build a JSON result.

The action is defined in the struts.xml file as : 

<action name="evts" class="org.project.controllers.json.EventsAction" method="executeEvts" >
  <result name="success" type="json">
    <param name="includeProperties">  		
	^day,
	events,
    	events\[\d+\],
    	events\[\d+\].id,
    </param>
  </result>
</action>

My Java action class EventsAction is defined as : 

public class EventsAction extends baseAction implements ModelDriven<TimetableManager>, Preparable { 

	public String getDay(){ return day; };
	public myModel getModels(){return ...;};
}

The JSON is working for events\[\d+\].id   :   getModels().getEvents().get(i).getId();

But not working for day : getDay() is not called.

I tried without ^, but no result.

My problem is I do not managed to make JSON result working without using the modelDriven returned object.

What I missed ? 

Cordialy and thanks for responses, 	


Matthieu MARC

---
Matthieu MARC
Responsable du Service Informatique
Centre Arts et Métiers Angers
Tel : 02 41 20 73 61



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


RE: JSon, includeProperties and modelDriven

Posted by Ma...@ensam.eu.
Thanks a lot, it resolved my problem

Adding : <param name="root">action</param>

Matthieu

---
Matthieu MARC
Responsable du Service Informatique
Centre Arts et Métiers Angers
Tel : 02 41 20 73 61

-----Message d'origine-----
De : maurizio.cucchiara@gmail.com [mailto:maurizio.cucchiara@gmail.com] De la part de Maurizio Cucchiara
Envoyé : jeudi 8 mars 2012 16:39
À : Struts Users Mailing List
Objet : Re: JSon, includeProperties and modelDriven

Hi Matthieu,
I have experienced the same issue today, referencing to the action element should fix the problem.
So try to add the follow line:

<action name="evts" class="org.project.controllers.json.EventsAction"
method="executeEvts" >
 <result name="success" type="json">
    ****<param name="root">action</root>****
   <param name="includeProperties">
       ^day,
       events,
       events\[\d+\],
       events\[\d+\].id,
   </param>
 </result>
</action>


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 5 March 2012 16:29, <Ma...@ensam.eu> wrote:

> TimetableManager

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


Re: JSon, includeProperties and modelDriven

Posted by hasegawa <qi...@gmail.com>.
thanks a lot



--
View this message in context: http://struts.1045723.n5.nabble.com/JSon-includeProperties-and-modelDriven-tp5537859p5710397.html
Sent from the Struts - User mailing list archive at Nabble.com.

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


Re: JSon, includeProperties and modelDriven

Posted by Maurizio Cucchiara <mc...@apache.org>.
Hi Matthieu,
I have experienced the same issue today, referencing to the action element
should fix the problem.
So try to add the follow line:

<action name="evts" class="org.project.controllers.json.EventsAction"
method="executeEvts" >
 <result name="success" type="json">
    ****<param name="root">action</root>****
   <param name="includeProperties">
       ^day,
       events,
       events\[\d+\],
       events\[\d+\].id,
   </param>
 </result>
</action>


Twitter     :http://www.twitter.com/m_cucchiara
G+          :https://plus.google.com/107903711540963855921
Linkedin    :http://www.linkedin.com/in/mauriziocucchiara

Maurizio Cucchiara


On 5 March 2012 16:29, <Ma...@ensam.eu> wrote:

> TimetableManager

Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Łukasz Lenart <lu...@googlemail.com>.
2012/4/5 Mounir Benzid <mb...@meetingmasters.de>:
> I finally contacted the author. His response is quite positive I would say
>  :-)
>
> As he pointed out we should also ask Zarar Siddiqi  for permission.
>
>
> Mounir
>
> ----
> Hi!
>
> Yes I'm the author / owner of the zapjava.com <http://zapjava.com> domain
> and also the content.
> Haven't had time to post much useful things there yet…
>
> YES - you may use and modify the class freely for documentation on ASF
> projects from my part
> (I use Apache projects daily and it's the least I can do to give something
> back to the community).
>
> It is how-ever loosely based on this:
> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
> <http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/>
> and as such I think you might want to check with Zarar Siddiqi also.
>
> With kind regards,
> Reigo Reinmets
>

Super, could attach a comment to that issue ?

https://issues.apache.org/jira/browse/WW-3778


Kind regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 22.03.2012 16:56, schrieb Łukasz Lenart:
> 2012/3/22 Mounir Benzid<mb...@meetingmasters.de>:
>> :-)   Ok, but actually this isn't my code and not even my blog. I just
>> stumbled over the solution while googling at 2 am .
>> So there is not connection between me and [1]. Sorry for the
>> misunderstanding.
>>
>> But I can contact the author and see if s/he is willing to donate the test
>> class to the ASF.
> Cool! Thanks in advance!
>
>
> Regards

I finally contacted the author. His response is quite positive I would 
say  :-)

As he pointed out we should also ask Zarar Siddiqi  for permission.


Mounir

----
Hi!

Yes I'm the author / owner of the zapjava.com <http://zapjava.com> 
domain and also the content.
Haven't had time to post much useful things there yet…

YES - you may use and modify the class freely for documentation on ASF 
projects from my part
(I use Apache projects daily and it's the least I can do to give 
something back to the community).

It is how-ever loosely based on this: 
http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/ 
<http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/>
and as such I think you might want to check with Zarar Siddiqi also.

With kind regards,
Reigo Reinmets


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Łukasz Lenart <lu...@googlemail.com>.
2012/3/22 Mounir Benzid <mb...@meetingmasters.de>:
> :-)   Ok, but actually this isn't my code and not even my blog. I just
> stumbled over the solution while googling at 2 am .
> So there is not connection between me and [1]. Sorry for the
> misunderstanding.
>
> But I can contact the author and see if s/he is willing to donate the test
> class to the ASF.

Cool! Thanks in advance!


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 22.03.2012 16:05, schrieb Łukasz Lenart:
> 2012/3/22 Mounir Benzid<mb...@meetingmasters.de>:
>> You mean some code demonstrating how I did my tests using [1]  ?
> An example would be nice, but I'm talking about your test class from
> the blog entry. It must be donated to ASF if I want to use it and the
> simplest way is to attach it as a patch to the issue.
>
>
> Regards
:-)   Ok, but actually this isn't my code and not even my blog. I just 
stumbled over the solution while googling at 2 am .
So there is not connection between me and [1]. Sorry for the 
misunderstanding.

But I can contact the author and see if s/he is willing to donate the 
test class to the ASF.

Mounir



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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Łukasz Lenart <lu...@googlemail.com>.
2012/3/22 Mounir Benzid <mb...@meetingmasters.de>:
> You mean some code demonstrating how I did my tests using [1]  ?

An example would be nice, but I'm talking about your test class from
the blog entry. It must be donated to ASF if I want to use it and the
simplest way is to attach it as a patch to the issue.


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 20.03.2012 11:26, schrieb Łukasz Lenart:
> Mounir
> could you prepare a patch with your test case class from here [1] and
> attach it to https://issues.apache.org/jira/browse/WW-3778 with
> granting license to ASF ? I'd like to include your code in S2
>
> [1] http://www.zapjava.com/tutorials/spring-struts2-junit4-annotations/
>
>
> Regards

You mean some code demonstrating how I did my tests using [1]  ?

Will do, but there's nothing fancy really (this weekend probably)

Mounir




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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Łukasz Lenart <lu...@googlemail.com>.
Mounir
could you prepare a patch with your test case class from here [1] and
attach it to https://issues.apache.org/jira/browse/WW-3778 with
granting license to ASF ? I'd like to include your code in S2

[1] http://www.zapjava.com/tutorials/spring-struts2-junit4-annotations/


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Christian Grobmeier <gr...@gmail.com>.
2012/3/20 Łukasz Lenart <lu...@googlemail.com>:
> As I see there is a small mess with the test classes. Struts 2 has
> three StrutsTestCase classes, in core in junit plugin and in testng
> plugin. It would be nice to clean them up. Remove StrutsTestCase from
> core and two other StrutsTestCase classes rename accordingly,
>
> Also adding support for the Convention plugin for both. Thoughts ?

Very much +1.

I am currently very busy, but I am willing to support this. But I will
take me a while to get some free slots.
Besides what you said, I have seen there is a "one testcase -> one
action" restriction. I think this should be removed too  I have
already looked into that, but didn't succeed with a solution.

Cheers
Christian

>
>
> Regards
> --
> Łukasz http://www.lenart.org.pl/
> mobile +48 606 323 122, office +27 11 0838747
> Warszawa JUG conference - Confitura http://confitura.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>



-- 
http://www.grobmeier.de
https://www.timeandbill.de

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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Łukasz Lenart <lu...@googlemail.com>.
As I see there is a small mess with the test classes. Struts 2 has
three StrutsTestCase classes, in core in junit plugin and in testng
plugin. It would be nice to clean them up. Remove StrutsTestCase from
core and two other StrutsTestCase classes rename accordingly,

Also adding support for the Convention plugin for both. Thoughts ?


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/

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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Mounir Benzid <mb...@meetingmasters.de>.
Am 19.03.2012 20:54, schrieb Łukasz Lenart:
> If you'll follow the last comments, you'll find another approach.
> Always you can prepare your solution and register an issue to
> integrate your solution with S2
>
>
> Regards

I found this blog post. So far this solves the problems I had with the 
old basestruts2testcase

http://www.zapjava.com/tutorials/spring-struts2-junit4-annotations/

Although it took me nearly two days to figure that out.

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


Re: Current status in testing with struts2, spring3 +junit 4?

Posted by Łukasz Lenart <lu...@googlemail.com>.
If you'll follow the last comments, you'll find another approach.
Always you can prepare your solution and register an issue to
integrate your solution with S2


Regards
-- 
Łukasz http://www.lenart.org.pl/
mobile +48 606 323 122, office +27 11 0838747
Warszawa JUG conference - Confitura http://confitura.pl/


2012/3/19 Mounir Benzid <mb...@meetingmasters.de>:
>
>
> A co-worker of mine discovered the below test helper class that we are
> currently employing for some very basic action testing stuff
> https://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
>
> Since this is from 2007 I'm wondering if this is still the best way
> posssible. For instance I'm not sure if the prepare() method
> is actually called using the above helper class.
>
> And what about  junit4? Still an issue ?
> http://struts.1045723.n5.nabble.com/NullPointerException-Using-StrutsSpringTestCase-td3534567.html
>
>
> Thanks again!
> Mounir
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

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


Current status in testing with struts2, spring3 +junit 4?

Posted by Mounir Benzid <mb...@meetingmasters.de>.

A co-worker of mine discovered the below test helper class that we are 
currently employing for some very basic action testing stuff
https://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/

Since this is from 2007 I'm wondering if this is still the best way 
posssible. For instance I'm not sure if the prepare() method
is actually called using the above helper class.

And what about  junit4? Still an issue ?
http://struts.1045723.n5.nabble.com/NullPointerException-Using-StrutsSpringTestCase-td3534567.html


Thanks again!
Mounir

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