Re: Setting object from param tag fails in Struts 2.2.1

2010-11-15 Thread Maurizio Cucchiara
What does your collection contain at runtime?

2010/11/15 Raj Nagappan r...@velocitylabs.com

 Hi, we recently upgraded from Struts 2.0.14 to 2.2.1 and I notice that

 the following JSP code to inject an object property from one action into
 another action has stopped working:

 s:if test=photoSet.keywordListLazyLoad != null
 s:action namespace=/search name=KeywordList executeResult=true
 ignoreContextParams=true
 s:param name=keywordList value=photoSet.keywordListLazyLoad/
 /s:action
 /s:if

 So it checks that the object is not null and then tries to set it on the
 parameter keywordList. This worked perfectly fine in 2.0.x, but in 2.2
 on the server side we get:

 java.lang.NoSuchMethodException:
 KeywordListAction.setKeywordList([Ljava.lang.String;)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1226)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
at

 ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
at
 ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)

 And the resulting error displayed on the web page is:

 Exception name: No result defined for action KeywordListAction and
 result input
 No result defined for action KeywordListAction and result input at

 com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
 at

 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
 at

 com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
 at

 org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept
 (AnnotationValidationInterceptor.java:68) at
 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept

 Is this a bug or do I need to do something differently for 2.2?

 Raj.



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




-- 
Maurizio Cucchiara


Validation xml for Radio button

2010-11-15 Thread Prabhubalaji Ragavan
Hi
I am using a radio option in my code. when i try to validate that thru the
validator.xml, the validation is not happening.

this is my jsp content.

s:radio label=Answer name=yourAnswer list=#{'1':'Yes','2':'No'} /

this is my validator.xml content

field name=yourAnswer
   field-validator type=fieldexpression
param name=expression![CDATA[(yourAnswer == 1)]]/param
messageenter gen1/message
/field-validator
/field


Please help, am new to struts2.

Thanks
Prabhu Ragavan


Alternative UrlRenderer bean

2010-11-15 Thread GF
Hello everyone.
i want to use a custom UrlRenderer bean.
reading Struts2 source code i found that is used to render the URLs
generated by s:url ..

If in my struts.xml I insert:

bean type=org.apache.struts2.components.UrlRenderer name=mystruts
class=org.apache.struts2.components.MyUrlRenderer/

Nothing happens, probably because Struts2 continue to inject the
renderer with struts name.

If in my struts.xml I insert

bean type=org.apache.struts2.components.UrlRenderer name=struts
class=org.apache.struts2.components.MyUrlRenderer/

the struts inizialization fails, since that bean with struts name is
already defined.

Any idea?

Thank you

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



Re: Alternative UrlRenderer bean

2010-11-15 Thread Nils-Helge Garli Hegvik
You can take a look at how the portlet plugin does this (which was
actually why the UrlRenderer bean was created in the first place). In
addition to defining the bean, you need to tell Struts to use your
renderer:

The portlet plugin does it like this:

bean type=org.apache.struts2.components.UrlRenderer name=portlet
class=org.apache.struts2.components.PortletUrlRenderer/
constant name=struts.urlRenderer value=portlet /

Nils-H

On Mon, Nov 15, 2010 at 12:37 PM, GF gan...@gmail.com wrote:
 Hello everyone.
 i want to use a custom UrlRenderer bean.
 reading Struts2 source code i found that is used to render the URLs
 generated by s:url ..

 If in my struts.xml I insert:

 bean type=org.apache.struts2.components.UrlRenderer name=mystruts
 class=org.apache.struts2.components.MyUrlRenderer/

 Nothing happens, probably because Struts2 continue to inject the
 renderer with struts name.

 If in my struts.xml I insert

 bean type=org.apache.struts2.components.UrlRenderer name=struts
 class=org.apache.struts2.components.MyUrlRenderer/

 the struts inizialization fails, since that bean with struts name is
 already defined.

 Any idea?

 Thank you

 -
 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: result type Jasper [Struts 2]

2010-11-15 Thread Dave Newton
On Mon, Nov 15, 2010 at 2:40 AM, @rju nagarjunabatt...@gmail.com wrote:
 Guys am also getting problem using jasper reports with struts 2.. please help
 me ASAP... same tutorial i too followed

...

How can anybody help if we have no idea what problem you're having?

Dave

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



Re: Setting object from param tag fails in Struts 2.2.1

2010-11-15 Thread Li Ying
[Ljava.lang.String; means a String array.

Looks like you are trying to copy a List from one action to another.

By somehow, struts2 is looking for a set method which take a String
array as it's parameter.



2010/11/15 Raj Nagappan r...@velocitylabs.com:
 Hi, we recently upgraded from Struts 2.0.14 to 2.2.1 and I notice that

 the following JSP code to inject an object property from one action into
 another action has stopped working:

 s:if test=photoSet.keywordListLazyLoad != null
 s:action namespace=/search name=KeywordList executeResult=true
 ignoreContextParams=true
 s:param name=keywordList value=photoSet.keywordListLazyLoad/
 /s:action
 /s:if

 So it checks that the object is not null and then tries to set it on the
 parameter keywordList. This worked perfectly fine in 2.0.x, but in 2.2
 on the server side we get:

 java.lang.NoSuchMethodException:
 KeywordListAction.setKeywordList([Ljava.lang.String;)
    at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1226)
    at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1474)
    at
 ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
    at
 ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)

 And the resulting error displayed on the web page is:

 Exception name: No result defined for action KeywordListAction and
 result input
 No result defined for action KeywordListAction and result input at
 com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:375)
 at
 com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)
 at
 com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
 at
 org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept
 (AnnotationValidationInterceptor.java:68) at
 com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept

 Is this a bug or do I need to do something differently for 2.2?

 Raj.



 -
 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: result type Jasper [Struts 2]

2010-11-15 Thread Brian Thompson
On Mon, Nov 15, 2010 at 7:08 AM, Dave Newton davelnew...@gmail.com wrote:

 On Mon, Nov 15, 2010 at 2:40 AM, @rju nagarjunabatt...@gmail.com wrote:
  Guys am also getting problem using jasper reports with struts 2.. please
 help
  me ASAP... same tutorial i too followed

 ...

 How can anybody help if we have no idea what problem you're having?

 Dave


Looks like a reply to this 2007 (!) post:

http://old.nabble.com/result-type-Jasper--Struts-2--td11004749.html

but I can't tell from this post whether he's having the same problem as was
detailed in that exchange.

-Brian


Putting an Image (in Bytes) on the session

2010-11-15 Thread Greg Akins
This seems like maybe I'm approaching it wrong.. but wondering if it's possible.

I'm wondering if I can put an image, in the form of a byte array, or
stream, that I can read with either a struts tag, jstl, or el

Thinking in my action

session.put(image, image.getBytes());

and in the .jsp

${image}

Thoughts on this, or other ways to do something similar?

-- 
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

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



Re: Putting an Image (in Bytes) on the session

2010-11-15 Thread Maurizio Cucchiara
You're right, it smells like a wrong approach :). Storing image's bytes is a
space consuming practice.

Anyway, Could you explain what do you need?


2010/11/15 Greg Akins angryg...@gmail.com

 This seems like maybe I'm approaching it wrong.. but wondering if it's
 possible.

 I'm wondering if I can put an image, in the form of a byte array, or
 stream, that I can read with either a struts tag, jstl, or el

 Thinking in my action

 session.put(image, image.getBytes());

 and in the .jsp

 ${image}

 Thoughts on this, or other ways to do something similar?

 --
 Greg Akins

 http://insomnia-consulting.org
 http://www.pghcodingdojo.org
 http://pittjug.dev.java.net
 http://twitter.com/akinsgre
 http://www.linkedin.com/in/akinsgre

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




-- 
Maurizio Cucchiara


Re: Putting an Image (in Bytes) on the session

2010-11-15 Thread Jesse Hill

Also, is there a particular reason why the data needs to go in the session
instead of just adding a getImage() method to your action that will return
the data that you need?

-Jesse


|
| From:  |
|
  
--|
  |Maurizio Cucchiara maurizio.cucchi...@gmail.com
 |
  
--|
|
| To:|
|
  
--|
  |Struts Users Mailing List user@struts.apache.org, angryg...@gmail.com  
 |
  
--|
|
| Date:  |
|
  
--|
  |11/15/2010 12:41 PM  
 |
  
--|
|
| Subject:   |
|
  
--|
  |Re: Putting an Image (in Bytes) on the session   
 |
  
--|





You're right, it smells like a wrong approach :). Storing image's bytes is
a
space consuming practice.

Anyway, Could you explain what do you need?


2010/11/15 Greg Akins angryg...@gmail.com

 This seems like maybe I'm approaching it wrong.. but wondering if it's
 possible.

 I'm wondering if I can put an image, in the form of a byte array, or
 stream, that I can read with either a struts tag, jstl, or el

 Thinking in my action

 session.put(image, image.getBytes());

 and in the .jsp

 ${image}

 Thoughts on this, or other ways to do something similar?

 --
 Greg Akins

 http://insomnia-consulting.org
 http://www.pghcodingdojo.org
 http://pittjug.dev.java.net
 http://twitter.com/akinsgre
 http://www.linkedin.com/in/akinsgre

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




--
Maurizio Cucchiara




Re: Putting an Image (in Bytes) on the session

2010-11-15 Thread Greg Akins
On Mon, Nov 15, 2010 at 12:49 PM, Jesse Hill jesse_h...@us.ibm.com wrote:

 Also, is there a particular reason why the data needs to go in the session 
 instead of just adding a getImage() method to your action that will return 
 the data that you need?


You're right.  I don't need it in the session.  But that wasn't the big problem.

The problem I was having was returning the image bytes from an in
page mechanism rather than relying on a dedicated image servlet
that writes directly to the response output.

I ended up writing a BufferedOutputStream onto the request and then
embedding a c:out value=${data}/ in an Img/ tag  like img
id=${caption} src=data:image/gif;base64,${data} alt=Image


--
Greg Akins

http://insomnia-consulting.org
http://www.pghcodingdojo.org
http://pittjug.dev.java.net
http://twitter.com/akinsgre
http://www.linkedin.com/in/akinsgre

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



Re: result type Jasper [Struts 2]

2010-11-15 Thread @rju

ok boss let me shou you my files
-struts.xml
?xml version=1.0 encoding=UTF-8 ?




 




/jasper/Report.jasper
myList
PDF




-
-web.xml
?xml version=1.0 encoding=UTF-8?

 
  struts2
  org.apache.struts2.dispatcher.FilterDispatcher
 
 
  struts2
  /*
 
 
  index.jsp
 




--
index.jsp

%@ page language=java import=java.util.* pageEncoding=ISO-8859-1%
%@ taglib uri=/struts-tags prefix=s %
%
String path = request.getContextPath();
String basePath =
request.getScheme()+://+request.getServerName()+:+request.getServerPort()+path+/;
%



  


My JSP 'index.jsp' starting page






  
  
  



  


-person.java---
package com;

public class Person {

private Long id;

private String name;

private String lastName;

public Person() {
}

public Person(String name, String lastName) {
this.name = name;
this.lastName = lastName;
}

public Person(Long id, String name, String lastName) {
this.id = id;
this.name = name;
this.lastName = lastName;
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
  
}

-JasperAction.java--
package com.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;


import net.sf.jasperreports.engine.JasperCompileManager;
import com.Person;



public class JasperAction extends ActionSupport {

/**
 * 
 */

private static final long serialVersionUID = 1L;
/** List to use as our JasperReports dataSource. */
private List myList;


public String execute() throws Exception {

// Create some imaginary persons.
Person p1 = new Person(new Long(1), Patrick, Lightbuddie);
Person p2 = new Person(new Long(2), Jason, Carrora);
Person p3 = new Person(new Long(3), Alexandru, Papesco);
Person p4 = new Person(new Long(4), Jay, Boss);

// Store people in our dataSource list (normally they would come
from a database).
myList = new ArrayList();
myList.add(p1);
myList.add(p2);
myList.add(p3);
myList.add(p4);

// Normally we would provide a pre-compiled .jrxml file
// or check to make sure we don't compile on every request.
try {
ServletContext context = null ; 

context = ServletActionContext.getServletContext();


JasperCompileManager.compileReportToFile(context.getRealPath(/jasper/Report.jrxml),context.getRealPath(/jasper/Report.jasper));
 

} catch (Exception e) {
e.printStackTrace();
return ERROR;
}

return SUCCESS;
}

public List getMyList() {
return myList;
}

}
---
This is the thing
and i have placed my Report.jrxml and Report.jasper in the directory called
jasper.
and i am trying to place this directory in every place i.e. once in
classes folder, root folder, web-inf folder i am trying all and project is
running Report button is coming but after pressing the Report Button am not
getting out put.. You can see the ouputs in my attachmens. namely
Output1,Output2. In that you can find the directory structure i have
flollowed Please Please help me...

http://old.nabble.com/file/p30225819/Output1.jpg 
http://old.nabble.com/file/p30225819/Output2.jpg 
-- 
View this message in context: 
http://old.nabble.com/result-type-Jasper--Struts-2--tp11004749p30225819.html
Sent from the Struts - User mailing list archive at Nabble.com.


Re: result type Jasper [Struts 2]

2010-11-15 Thread Dave Newton
I can't actually see anything, but do you have an action configured
for the report?

On Mon, Nov 15, 2010 at 11:34 PM, @rju nagarjunabatt...@gmail.com wrote:

 ok boss let me shou you my files
 -struts.xml
 ?xml version=1.0 encoding=UTF-8 ?









                        /jasper/Report.jasper
                        myList
                        PDF




 -
 -web.xml
 ?xml version=1.0 encoding=UTF-8?


  struts2
  org.apache.struts2.dispatcher.FilterDispatcher


  struts2
  /*


  index.jsp





 --
 index.jsp

 %@ page language=java import=java.util.* pageEncoding=ISO-8859-1%
 %@ taglib uri=/struts-tags prefix=s %
 %
 String path = request.getContextPath();
 String basePath =
 request.getScheme()+://+request.getServerName()+:+request.getServerPort()+path+/;
 %




    

    My JSP 'index.jsp' starting page














 
 -person.java---
 package com;

 public class Person {

    private Long id;

    private String name;

    private String lastName;

    public Person() {
    }

    public Person(String name, String lastName) {
        this.name = name;
        this.lastName = lastName;
    }

    public Person(Long id, String name, String lastName) {
        this.id = id;
        this.name = name;
        this.lastName = lastName;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

 }
 
 -JasperAction.java--
 package com.action;

 import java.util.ArrayList;
 import java.util.List;

 import javax.servlet.ServletContext;

 import org.apache.struts2.ServletActionContext;
 import com.opensymphony.xwork2.ActionSupport;


 import net.sf.jasperreports.engine.JasperCompileManager;
 import com.Person;



 public class JasperAction extends ActionSupport {

    /**
         *
         */

        private static final long serialVersionUID = 1L;
        /** List to use as our JasperReports dataSource. */
    private List myList;


        public String execute() throws Exception {

        // Create some imaginary persons.
        Person p1 = new Person(new Long(1), Patrick, Lightbuddie);
        Person p2 = new Person(new Long(2), Jason, Carrora);
        Person p3 = new Person(new Long(3), Alexandru, Papesco);
        Person p4 = new Person(new Long(4), Jay, Boss);

        // Store people in our dataSource list (normally they would come
 from a database).
        myList = new ArrayList();
        myList.add(p1);
        myList.add(p2);
        myList.add(p3);
        myList.add(p4);

        // Normally we would provide a pre-compiled .jrxml file
        // or check to make sure we don't compile on every request.
        try {
                ServletContext context = null ;

                context = ServletActionContext.getServletContext();


 JasperCompileManager.compileReportToFile(context.getRealPath(/jasper/Report.jrxml),context.getRealPath(/jasper/Report.jasper));


        } catch (Exception e) {
            e.printStackTrace();
            return ERROR;
        }

        return SUCCESS;
    }

    public List getMyList() {
        return myList;
    }

 }
 ---
 This is the thing
 and i have placed my Report.jrxml and Report.jasper in the directory called
 jasper.
 and i am trying to place this directory in every place i.e. once in
 classes folder, root folder, web-inf folder i am trying all and project is
 running Report button is coming but after pressing the Report Button am not
 getting out put.. You can see the ouputs in my attachmens. namely
 Output1,Output2. In that you can find the directory structure i have
 flollowed Please Please help me...

 http://old.nabble.com/file/p30225819/Output1.jpg
 http://old.nabble.com/file/p30225819/Output2.jpg
 --
 View this message in context: 
 http://old.nabble.com/result-type-Jasper--Struts-2--tp11004749p30225819.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