Tag iterator and my object container

2011-05-10 Thread Matthieu.Marc
Hi everybody,

I have a container object SearchResults which contains a treeMap of simple 
object SearchResult.

I want to iterate over SearchResults in order to display properties of all 
SearchResult object

Class SearchResult {
//getter and setter
getDescription();
}

Class SearchResults {
  treeMapString, SearchResult  resultats;

public SetString keyset();
public IteratorString iterator();
public SearchResult get(String key);
}

My Action class have this getter :

getResultats(){ return (SearchResults)object; };

And my JSP look like :

s:iterator value=resultats
s:property value=description /
/s:iterator


But it is not working, s:iterator tag is not iterating over my SearchResults 
object using the iterator() method (not called).

How must I construct my SearchResults object in order to make the s:iterator 
tag iterate over it ?

Thanks.

Matthieu MARC

---
Matthieu MARC
Responsable du Service Informatique du Centre d'Angers
Arts et Métiers ParisTech
Tél : 02 41 20 73 61


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



Re: how to use ajax displaytag?

2011-05-10 Thread elakkiya
hi,
I have one display-tag in my jsp page. I got the contents of the
display tag through ajax response.

I need to set the display tag from that response using jquery. Please any
one help me in this.


--
View this message in context: 
http://struts.1045723.n5.nabble.com/how-to-use-ajax-displaytag-tp3498180p4383883.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



Re: how to use ajax displaytag?

2011-05-10 Thread Eric Lentz
 I have one display-tag in my jsp page. I got the contents of the
 display tag through ajax response.

 I need to set the display tag from that response using jquery. Please 
any
 one help me in this.

That's not a Struts question.

Ask your question on stackoverflow.com with a jquery and displaytag 
tags on the question and I'll answer it.


Re: Tag iterator and my object container

2011-05-10 Thread Steven Yang
you need to implement the Iterator interface

On Tue, May 10, 2011 at 4:14 PM, matthieu.m...@ensam.eu wrote:

 Hi everybody,

 I have a container object SearchResults which contains a treeMap of simple
 object SearchResult.

 I want to iterate over SearchResults in order to display properties of all
 SearchResult object

Class SearchResult {
//getter and setter
getDescription();
}

Class SearchResults {
  treeMapString, SearchResult  resultats;

public SetString keyset();
public IteratorString iterator();
public SearchResult get(String key);
}

 My Action class have this getter :

getResultats(){ return (SearchResults)object; };

 And my JSP look like :

s:iterator value=resultats
s:property value=description /
/s:iterator


 But it is not working, s:iterator tag is not iterating over my
 SearchResults object using the iterator() method (not called).

 How must I construct my SearchResults object in order to make the
 s:iterator tag iterate over it ?

 Thanks.

 Matthieu MARC

 ---
 Matthieu MARC
 Responsable du Service Informatique du Centre d'Angers
 Arts et Métiers ParisTech
 Tél : 02 41 20 73 61


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




@DateRangeFieldValidator

2011-05-10 Thread Mohamed SIDI
Hello all,

I'm looking tu use the @DateRangeFieldValidator annotation for validating a
date, my questions :

1. there are ways to customize the date format, I have to convert the min
and max attributes values for the local
2. can I use a format for the string representing the date (dd/MM/,
/MM/dd,dd-MM-, .)

thank for helping me

-- 


Cordialement

Mohamed


javascript array to Struts 2 action

2011-05-10 Thread srsankar
i am having a array of strings on javascript and i would like to make an ajax
call to struts 2 action which expects ListString. I need to know a way to
pass these values to action which will recognize it. If i pass the array
directly, SOP is printing it as an Object and it couldnt able to cast it to
java List. Please help me to identify how to do this. thanks.

--
View this message in context: 
http://struts.1045723.n5.nabble.com/javascript-array-to-Struts-2-action-tp4384471p4384471.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



jsp's outside WEB-INF in maven archetype?

2011-05-10 Thread Miguel
The other day I tried out a simple maven archetype (either
struts2-archetype-starter or -convention, I don't recall). Anyway, it's
one that comes configured with sitemesh.

What stroke me as odd was that the sample jsp's were in the path
src/webapp/jsp, and not inside WEB-INF.

Isn't it preferable to store the jsp's inside WEB-INF (to reduce their
visibility)? If so, shouldn't the archetypes be changed in accordance? 

Regards,

Miguel Almeida


string concatenation within an EL conditional

2011-05-10 Thread Scott Koenig
Hello,

This may fall under nested EL expressions, which to my understanding are
intentionally disallowed, but I was wondering if there was EL syntax that
would support what I am trying to do, namely, set a URL based on a
conditional, or if I should stick with s:if.

Currently I have

s:if test=mn == #m.name
a href=#landing${m.dispName}/a
/s:if
s:else
a href=/internal!m?cName=${cName}mName=${m.name}${m.dispName}/a
/s:else

but would like to do it in a single line, something like

a href=${mn == m.name ? '#landing' : '/internal!m?cName=' + cName +
'mName=' + m.name}${m.dispName}/a

Is this possible?

Thanks,
~~Scott


Re: string concatenation within an EL conditional

2011-05-10 Thread Dave Newton
On Tue, May 10, 2011 at 11:44 AM, Scott Koenig wrote:
 This may fall under nested EL expressions, which to my understanding are
 intentionally disallowed, but I was wondering if there was EL syntax that
 would support what I am trying to do, namely, set a URL based on a
 conditional, or if I should stick with s:if.

 Currently I have

 s:if test=mn == #m.name
    a href=#landing${m.dispName}/a
 /s:if
 s:else
    a href=/internal!m?cName=${cName}mName=${m.name}${m.dispName}/a
 /s:else

 but would like to do it in a single line, something like

 a href=${mn == m.name ? '#landing' : '/internal!m?cName=' + cName + 
 'mName=' + m.name}${m.dispName}/a

Yuck; unreadable. Stick it in a custom tag where it belongs. That much
computation doesn't belong in the mainline JSP.

Does the one-liner version not work?

Dave

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



Re: string concatenation within an EL conditional

2011-05-10 Thread Maurizio Cucchiara
I don't know if it works and/or it what you're looking for, but it
worths at least a try:

s:a action=internal namespace=/
  s:if test=mn != #m.name
 s:param name=cName value=${cName}/
  /s:if
${m.dispName}
/s:a

Please let me know if it works.

On 10 May 2011 17:44, Scott Koenig scott.l.koe...@gmail.com wrote:
 Hello,

 This may fall under nested EL expressions, which to my understanding are
 intentionally disallowed, but I was wondering if there was EL syntax that
 would support what I am trying to do, namely, set a URL based on a
 conditional, or if I should stick with s:if.

 Currently I have

 s:if test=mn == #m.name
    a href=#landing${m.dispName}/a
 /s:if
 s:else
    a href=/internal!m?cName=${cName}mName=${m.name}${m.dispName}/a
 /s:else

 but would like to do it in a single line, something like

 a href=${mn == m.name ? '#landing' : '/internal!m?cName=' + cName +
 'mName=' + m.name}${m.dispName}/a

 Is this possible?

 Thanks,
 ~~Scott




-- 
Maurizio Cucchiara

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



How to test json output from json plugin?

2011-05-10 Thread Jim Talbut
Hi,

I've got an action declared as:
@Results( {
@Result( name=success, type=json, params={ root, schools } )
})
@Namespace(/json)
@ParentPackage(json-default)
public class SchoolSearchAction extends ActionSupport {


and I have a test class that is able to get hold of the actionProxy, the 
actionInvocation, etc.

The question is, how, from the test class can I get hold of the json produced 
by the JSON result?

Thanks

Jim


Re: How to test json output from json plugin?

2011-05-10 Thread Frans Thamura
we have full json=struts-spring-hibernate apps

please checkout from http://cimande.java.net

it is using maven, but little tricky

use mysql


F

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



Re: javascript array to Struts 2 action

2011-05-10 Thread Paweł Wielgus
Hi,
try with String[] field in your action,
or create a custom field setter that will take String[] as a parameter.
I also assume that on your page You are submiting it as an array?

Best greetings,
Paweł Wielgus.


2011/5/10 srsankar sriram.it...@gmail.com:
 i am having a array of strings on javascript and i would like to make an ajax
 call to struts 2 action which expects ListString. I need to know a way to
 pass these values to action which will recognize it. If i pass the array
 directly, SOP is printing it as an Object and it couldnt able to cast it to
 java List. Please help me to identify how to do this. thanks.

 --
 View this message in context: 
 http://struts.1045723.n5.nabble.com/javascript-array-to-Struts-2-action-tp4384471p4384471.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



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



Re: Strange behaviour with Spring

2011-05-10 Thread Marcus Bond
Just in case anyone can benefit from the insight, it turned out to be a 
configuration option and unfortunately that property isn't mentioned in 
the default properties file. (perhaps it could be added?)


In spite of configuring the struts properties for spring like below 
(properties as found in the default struts properties file)

struts.objectFactory=spring
struts.objectFactory.spring.autoWire=name
struts.objectFactory.spring.useClassCache=true

It turns out that even when configured in this way the 
StrutsSpringObjectFactory doesn't enforce it and can still load by type 
(only if there is a single bean of the relevant type as per behaviour of 
autowire by type) when trying to resolve constructors unless the 
following property is also set..


#This must be set to true when autowiring by name to prevent the 
StrutsSpringObjectFactory autowiring by type!

struts.objectFactory.spring.autoWire.alwaysRespect=true

Problem solved, cheers,
M.

On 09/05/2011 17:29, Andrew Lee wrote:

Ok, I didn't see you aren't actually referencing the string bean in your
action. That won't help
On 9 May 2011 17:23, Andrew Leeplasma...@gmail.com  wrote:

He's not using it as a java bean. Spring beans can be immutable.

Is it because when spring wires up your action it considers it to be a
parameter as you have get and set methods? So it appends it to the url. If
you inject t string bean via constructor injection and not via setter
injection and remove the getters and setters ,does that work?
On 9 May 2011 16:54, Chris Prattthechrispr...@gmail.com  wrote:

Even if Spring considers it valid, that doesn't mean that other packages
will be able to treat immutable, non-JavaBeans as JavaBeans.
(*Chris*)

On Mon, May 9, 2011 at 3:39 AM, Marcusmar...@marcusbond.co.uk  wrote:


You can if you want to use a String as a Spring bean, it's a different
issue as to whether or not it is considered best practice or whether

there

are alternatives. You can find examples on the SpringSource forum if you
want, commented upon by Springy folk. It is perfectly valid to do so..

Sorry to sound off here but could input to the topic be constrained to

why

it might be that Struts somehow messes up the redirect by picking this

bean

up even though there are no references to it an any of the struts action
beans or in the struts.xml.. I think we can infer from this that if any
context file, regardless of purpose (related to Struts, data access or

any

other whatever) declared a String as a bean this will mess struts

redirects

up.. which is something that shouldn't happen.




On 09/05/2011 11:16, Ilya Kazakevich wrote:


Not sure you can use primitive wrappers and strings as spring beans.

For

example autowiring does not work for them.
Try the following:

1) inject literal directly
Instead of
property ref=myString
Try
property value=myStringContent

2) Create your own wrapper for string like Configuration class with

method

getMyProperty


Ilya Kazakevich,
Developer
JetBrains Inc
http://www.jetbrains.com
Develop with pleasure!

-Original Message-
From: Marcus [mailto:mar...@marcusbond.co.uk]
Sent: Monday, May 09, 2011 11:27 AM
To: user@struts.apache.org
Subject: Re: Strange behaviour with Spring

Not sure what you mean, the bean I'm referring to is a Spring bean not

a

JavaBean (two unrelated concepts).. there is no requirement when using
the Spring framework to not create Spring beans of type String.

Regardless, this doesn't help explain why the String is being picked up
by the Struts framework and set on the redirect when there is nothing

in

the configuration to indicate it should..

On 09/05/2011 07:13, Chris Pratt wrote:


You can't create beans that implement java.lang.String, it's immutable
and
doesn't follow the bean spec.
(*Chris*)

On Sun, May 8, 2011 at 2:11 PM, Marcus Bondmar...@marcusbond.co.uk


wrote:


Hi,

I'm using Struts 2.2.3 and have observed some bizarre behavior when
using
Spring to provide my actions.. In order to simplify this and prove

the

problem I have created a project with a single static html file, and

a

single action in struts.xml which references a bean in my spring

context

file.

What basically happens is that if I declare a bean in my spring

context

(bean unrelated toany struts action) that is of class

java.lang.String

(as I
do for a log4j filepath) then when I perform a redirect in an action
mapping
this gets appended to the end of the url as the anchor.

If I navigate to http://localhost:8080/My App/simpleRedirect
the result is a reirect to the 'simple' action but note the url

struts

has
redirected to:




http://localhost:8080/MyApp/simple#this%20is%20a%20java.lang.String%20bean%2

0in%20my%20spring%20context


For some reason the

org.apache.struts2.dispatcher.ServletRedirectResult

class is being instantiated by with the anchor and location

constructor

args
set to the value of my spring bean by the StrutsSpringObjectFactory

If I remove the String bean from the spring contect then 

RedirectAction Help!

2011-05-10 Thread Teresa McGinley
I am trying to send an id from one action to another and it seems to be
sending a null.  Please assist and I am really at my wits end with this.
How do I get the formId from the Listing to the QuestionListing?

startInformation has a yourForm=41, when I click the Begin button I get the
redirect to Questions.action with a null formId as shown...

http://localhost:8080/IUNSurvey/survey/Questions.action?formId=

startInformation.jsp has a button that calls redirect:

s:form action=beginQuestions
...
s:submit type=submit value=Begin align=right/


struts.xml

?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE struts PUBLIC
-//Apache Software Foundation//DTD Struts Configuration 2.0//EN
http://struts.apache.org/dtds/struts-2.0.dtd;

struts
constant name=struts.devMode value=true / !-- set to false for
prod --

package name= namespace=/survey extends=struts-default
action name=Listing class=actions.survey.Listing
method=display
result name=none/views/survey/Listing.jsp/result
/action

action name=startInformation class=actions.survey.Listing
result
name=success/views/survey/startInformation.jsp/result
/action

action name=beginQuestions class=actions.survey.Listing
method=beginQuestions
result name=redirect type=redirectAction
param name=actionNameQuestions/param
param name=parsetrue/param
param name=formId${yourForm}/param
/result
/action

action name=Questions class=actions.survey.QuestionListing
result name=none/views/survey/Questions.jsp/result
/action

/package
/struts

exerpt from Listing.java

public String execute() {
selectedForm = services.getFormsById(yourForm);
return SUCCESS;
}

public String display() {
forms = services.getForms();
return NONE;
}

public String beginQuestions() {
return redirect;
}

/**
 * @return the yourForm
 */
public Long getYourForm() {
return yourForm;
}


exerpt from QuestionListing.java

I have a getter/setter for formId

public String execute() {
currentQuestion = (services.getQuestionsByForm(getFormId()));
return SUCCESS;
}

public String display() {
setCurrentQuestion(services.getQuestionsByForm(getFormId()));
return NONE;
}
public void setFormId(Long formId) {
this.formId = formId;
}

public Long getFormId() {
return formId;
}


Re: RedirectAction Help!

2011-05-10 Thread Amol Ghotankar
Hi,

My experience say not always just getter  setters works.

So try to use

ActionContext - get context - getvalue stack. set
or
ActionContext - get context - getvalue stack. push

If only problem is formId not available to OGNL during redirect.

There any be some other issue which needs more investigation .

On Wed, May 11, 2011 at 4:31 AM, Teresa McGinley tdmcgin...@gmail.comwrote:

 I am trying to send an id from one action to another and it seems to be
 sending a null.  Please assist and I am really at my wits end with this.
 How do I get the formId from the Listing to the QuestionListing?

 startInformation has a yourForm=41, when I click the Begin button I get the
 redirect to Questions.action with a null formId as shown...

 http://localhost:8080/IUNSurvey/survey/Questions.action?formId=

 startInformation.jsp has a button that calls redirect:

 s:form action=beginQuestions
 ...
 s:submit type=submit value=Begin align=right/


 struts.xml

 ?xml version=1.0 encoding=UTF-8 ?
 !DOCTYPE struts PUBLIC
-//Apache Software Foundation//DTD Struts Configuration 2.0//EN
http://struts.apache.org/dtds/struts-2.0.dtd;

 struts
constant name=struts.devMode value=true / !-- set to false for
 prod --

package name= namespace=/survey extends=struts-default
action name=Listing class=actions.survey.Listing
 method=display
result name=none/views/survey/Listing.jsp/result
/action

action name=startInformation class=actions.survey.Listing
result
 name=success/views/survey/startInformation.jsp/result
/action

action name=beginQuestions class=actions.survey.Listing
 method=beginQuestions
result name=redirect type=redirectAction
param name=actionNameQuestions/param
param name=parsetrue/param
param name=formId${yourForm}/param
/result
/action

action name=Questions class=actions.survey.QuestionListing
result name=none/views/survey/Questions.jsp/result
/action

/package
 /struts

 exerpt from Listing.java

public String execute() {
selectedForm = services.getFormsById(yourForm);
return SUCCESS;
}

public String display() {
forms = services.getForms();
return NONE;
}

public String beginQuestions() {
return redirect;
}

/**
 * @return the yourForm
 */
public Long getYourForm() {
return yourForm;
}


 exerpt from QuestionListing.java

 I have a getter/setter for formId

public String execute() {
currentQuestion = (services.getQuestionsByForm(getFormId()));
return SUCCESS;
}

public String display() {
setCurrentQuestion(services.getQuestionsByForm(getFormId()));
return NONE;
}
public void setFormId(Long formId) {
this.formId = formId;
}

public Long getFormId() {
return formId;
}




-- 


With Best Regards,

Amol Ghotankar
Technical Lead
Cursive Technologies Pvt. Ltd.
104, A1 Wing, W Sector,
Masulkar Colony, Ajmera,
Pimpri, Pune-18 INDIA
O: +91 2020 270 570
M: +91 9960 980 419
www.cursivetech.com


CURSIVE TECHNOLOGIES EMAIL NOTICE
The information contained in this email and any attachments is confidential
and may be subject to copyright or other intellectual property protection.
If you are not the intended recipient, you are not authorized to use or
disclose this information, and we request that you notify us by reply mail
or telephone and delete the original message from your mail system.