[Stripes-users] Problem with Stripes:param

2015-02-26 Thread Nahid Seidi
Hi

I am sending some variables from stripes:param to another actionbean in
order to show them in another jsp file. The problem is that if a variable
has non-english characters like (ä,ö,...) stripes:param encode them to some
wired format. I used ecoding tags in my jsp but doesn't work. Since
stripes:param is inside a stripes:link, could it be something with
stripes:link? For example if 'fname' in first jsp has a character like 'ö'
stripes converts it to some other characters when it shows it in second
jsp! I don't think it's about encoding, because the characters are shown
correctly in first jsp but when I pass them using stripes:param they're
changed somehow!

first jsp




edit

StudentEditExcelAction.java

@UrlBinding("/Student/editExcel.action")public class
StudentEditExcelAction implements ActionBean {
private String fname;private String lname;
@DefaultHandler@DontValidatepublic Resolution edit() {
return forward("editExcel");}
@DontValidatepublic Resolution loadStudent() {
System.out.println("utbildare: " + school); //TODO delete this later
return forward("editExcel");}

second jsp














--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Problem with Stripes:param

2015-02-27 Thread Nahid Seidi
Rick,

I already tried the encoding tag, but it doesn't work. As I said, I don't
think the problem is with encoding because as you see in the first jsp I
get 'fname' form an actionbean and then send that to another one. Since
'fname' is shown correctly in first jsp but not in second jsp so I don't
think it is about encoding. I wonder if there is another way to pass
parameters (fname, lname) to the other jsp using something other than
stripes:param ?



On Fri, Feb 27, 2015 at 1:11 AM, Rick Grashel  wrote:

> Nahid,
>
> I've never had a problem with encoding the contents of a parameter.  Try
> again with this at the very top of your JSP or the very top of your stripes
> template:
>
> <%@ page contentType="text/html; charset=UTF-8" %>
>
> Thanks.
>
> -- Rick
>
> On Thu, Feb 26, 2015 at 5:27 PM, Nahid Seidi 
> wrote:
>
>> Hi
>>
>> I am sending some variables from stripes:param to another actionbean in
>> order to show them in another jsp file. The problem is that if a variable
>> has non-english characters like (ä,ö,...) stripes:param encode them to some
>> wired format. I used ecoding tags in my jsp but doesn't work. Since
>> stripes:param is inside a stripes:link, could it be something with
>> stripes:link? For example if 'fname' in first jsp has a character like 'ö'
>> stripes converts it to some other characters when it shows it in second
>> jsp! I don't think it's about encoding, because the characters are shown
>> correctly in first jsp but when I pass them using stripes:param they're
>> changed somehow!
>>
>> first jsp
>>
>> > beanclass="se.theducation.course.ui.action.student.StudentEditExcelAction" 
>> event="loadStudent" >
>> 
>> > />
>> edit
>>
>> StudentEditExcelAction.java
>>
>> @UrlBinding("/Student/editExcel.action")public class StudentEditExcelAction 
>> implements ActionBean {
>> private String fname;private String lname;
>> @DefaultHandler@DontValidatepublic Resolution edit() {
>> return forward("editExcel");}
>> @DontValidatepublic Resolution loadStudent() {
>> System.out.println("utbildare: " + school); //TODO delete this later
>> return forward("editExcel");}
>>
>> second jsp
>>
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>
>>
>>
>>
>> --
>> Dive into the World of Parallel Programming The Go Parallel Website,
>> sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub
>> for all
>> things parallel software development, from weekly thought leadership
>> blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>> ___
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
>
> --
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Problem with Stripes:param

2015-02-27 Thread Nahid Seidi
Hi Gérald

I'm using Resin. I guess I need to find out how to do the configuration you
sent in resin.

/Nahid

On Friday, February 27, 2015, Gérald Quintana 
wrote:

> Hello,
>
> If you're using Tomcat:
>
>- Such a filter is provided by Tomcat:
>
> https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/filters/SetCharacterEncodingFilter.html
>- Or you can force Tomcat to use UTF-8 at the Connector level: <
>Connector port="8080" *URIEncoding="UTF-8"*/>
>
> Gérald
>
> 2015-02-27 11:07 GMT+01:00 VANKEISBELCK Remi  >:
>
>> Hi,
>>
>> I'd say Nestor is right. You app server is probably using platform locale.
>>
>> You probably want this kind of filter :
>>
>> https://github.com/pojosontheweb/woko/blob/develop/core/src/main/java/woko/util/SetCharacterEncodingFilter.java
>>
>> And configure it to use utf-8.
>>
>> Cheers
>>
>> Rémi
>>
>>
>> 2015-02-27 9:42 GMT+01:00 Nahid Seidi > >:
>>
>>> Rick,
>>>
>>> I already tried the encoding tag, but it doesn't work. As I said, I
>>> don't think the problem is with encoding because as you see in the first
>>> jsp I get 'fname' form an actionbean and then send that to another one.
>>> Since 'fname' is shown correctly in first jsp but not in second jsp so I
>>> don't think it is about encoding. I wonder if there is another way to pass
>>> parameters (fname, lname) to the other jsp using something other than
>>> stripes:param ?
>>>
>>>
>>>
>>> On Fri, Feb 27, 2015 at 1:11 AM, Rick Grashel >> > wrote:
>>>
>>>> Nahid,
>>>>
>>>> I've never had a problem with encoding the contents of a parameter.
>>>> Try again with this at the very top of your JSP or the very top of your
>>>> stripes template:
>>>>
>>>> <%@ page contentType="text/html; charset=UTF-8" %>
>>>>
>>>> Thanks.
>>>>
>>>> -- Rick
>>>>
>>>> On Thu, Feb 26, 2015 at 5:27 PM, Nahid Seidi >>> > wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> I am sending some variables from stripes:param to another actionbean
>>>>> in order to show them in another jsp file. The problem is that if a
>>>>> variable has non-english characters like (ä,ö,...) stripes:param encode
>>>>> them to some wired format. I used ecoding tags in my jsp but doesn't work.
>>>>> Since stripes:param is inside a stripes:link, could it be something with
>>>>> stripes:link? For example if 'fname' in first jsp has a character like 'ö'
>>>>> stripes converts it to some other characters when it shows it in second
>>>>> jsp! I don't think it's about encoding, because the characters are shown
>>>>> correctly in first jsp but when I pass them using stripes:param they're
>>>>> changed somehow!
>>>>>
>>>>> first jsp
>>>>>
>>>>> >>>> beanclass="se.theducation.course.ui.action.student.StudentEditExcelAction"
>>>>>  event="loadStudent" >
>>>>> >>>> value="${array.getStudent().getFirstName() }" />
>>>>> 
>>>>> edit
>>>>>
>>>>> StudentEditExcelAction.java
>>>>>
>>>>> @UrlBinding("/Student/editExcel.action")public class 
>>>>> StudentEditExcelAction implements ActionBean {
>>>>> private String fname;private String lname;
>>>>> @DefaultHandler@DontValidatepublic Resolution edit() {
>>>>> return forward("editExcel");}
>>>>> @DontValidatepublic Resolution loadStudent() {
>>>>> System.out.println("utbildare: " + school); //TODO delete this later
>>>>> return forward("editExcel");}
>>>>>
>>>>> second jsp
>>>>>
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>>

Re: [Stripes-users] Problem with Stripes:param

2015-02-27 Thread Nahid Seidi
Thank you everyone for your answers. I added the following in web.xml and
it works now! But it's also weird to me how Spring MVC affects on encoding!


CharacterEncodingFilter
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8



CharacterEncodingFilter
/*
  

/Nahid

On Fri, Feb 27, 2015 at 11:52 AM, Nahid Seidi  wrote:

> Hi Gérald
>
> I'm using Resin. I guess I need to find out how to do the configuration
> you sent in resin.
>
> /Nahid
>
>
> On Friday, February 27, 2015, Gérald Quintana 
> wrote:
>
>> Hello,
>>
>> If you're using Tomcat:
>>
>>- Such a filter is provided by Tomcat:
>>
>> https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/filters/SetCharacterEncodingFilter.html
>>- Or you can force Tomcat to use UTF-8 at the Connector level: <
>>Connector port="8080" *URIEncoding="UTF-8"*/>
>>
>> Gérald
>>
>> 2015-02-27 11:07 GMT+01:00 VANKEISBELCK Remi :
>>
>>> Hi,
>>>
>>> I'd say Nestor is right. You app server is probably using platform
>>> locale.
>>>
>>> You probably want this kind of filter :
>>>
>>> https://github.com/pojosontheweb/woko/blob/develop/core/src/main/java/woko/util/SetCharacterEncodingFilter.java
>>>
>>> And configure it to use utf-8.
>>>
>>> Cheers
>>>
>>> Rémi
>>>
>>>
>>> 2015-02-27 9:42 GMT+01:00 Nahid Seidi :
>>>
>>>> Rick,
>>>>
>>>> I already tried the encoding tag, but it doesn't work. As I said, I
>>>> don't think the problem is with encoding because as you see in the first
>>>> jsp I get 'fname' form an actionbean and then send that to another one.
>>>> Since 'fname' is shown correctly in first jsp but not in second jsp so I
>>>> don't think it is about encoding. I wonder if there is another way to pass
>>>> parameters (fname, lname) to the other jsp using something other than
>>>> stripes:param ?
>>>>
>>>>
>>>>
>>>> On Fri, Feb 27, 2015 at 1:11 AM, Rick Grashel 
>>>> wrote:
>>>>
>>>>> Nahid,
>>>>>
>>>>> I've never had a problem with encoding the contents of a parameter.
>>>>> Try again with this at the very top of your JSP or the very top of your
>>>>> stripes template:
>>>>>
>>>>> <%@ page contentType="text/html; charset=UTF-8" %>
>>>>>
>>>>> Thanks.
>>>>>
>>>>> -- Rick
>>>>>
>>>>> On Thu, Feb 26, 2015 at 5:27 PM, Nahid Seidi 
>>>>> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> I am sending some variables from stripes:param to another actionbean
>>>>>> in order to show them in another jsp file. The problem is that if a
>>>>>> variable has non-english characters like (ä,ö,...) stripes:param encode
>>>>>> them to some wired format. I used ecoding tags in my jsp but doesn't 
>>>>>> work.
>>>>>> Since stripes:param is inside a stripes:link, could it be something with
>>>>>> stripes:link? For example if 'fname' in first jsp has a character like 
>>>>>> 'ö'
>>>>>> stripes converts it to some other characters when it shows it in second
>>>>>> jsp! I don't think it's about encoding, because the characters are shown
>>>>>> correctly in first jsp but when I pass them using stripes:param they're
>>>>>> changed somehow!
>>>>>>
>>>>>> first jsp
>>>>>>
>>>>>> >>>>> beanclass="se.theducation.course.ui.action.student.StudentEditExcelAction"
>>>>>>  event="loadStudent" >
>>>>>> >>>>> value="${array.getStudent().getFirstName() }" />
>>>>>> >>>>> value="${array.getStudent().getLastName() }" />
>>>>>> edit
>>>>>>
>>>>>> StudentEditExcelAction.java
>>>>>>
>>>>>> @UrlBinding("/Student/editExcel.action")public class 
>>>>>> StudentEditExcelAction implements ActionBean {
>>>>>> private String fname;private String lname;
>>>&

[Stripes-users] SessionScope hides Stripes:errors

2015-02-27 Thread Nahid Seidi
I need to use @SessionScope to make a list stay in the page after
refreshing, but when I use it, Stripes:error doesn't display error any
more. Stripes:error works actually(error is on a field in which user needs
to input and if the field is empty, error is showing and user can not
submit the form) because the submission is disabled, but it just doesn't
show the error message in the page any more. I think there is something
with @SessionScope because when I run the code without it all the errors
shown in the page. Any Idea of how to fix this?

Note: I also tried to use @Wizard(startEvents="event") and it lets errors
to be shown but doesn't do anything with saving the list in the page!
Here is java code:

@SessionScope
@UrlBinding("/Student/import.action")
public class ImportAction implements ActionBean {

  private List importExcel;
private String userCheckBox;

public Resolution importStudents() throws IOException {

try {
//Here I put data into importExcel list
} catch {}

  if (userCheckBox == null) {
  if(importExcel.size() > 0) {
  for(String error : importExcel) {
  this.getContext().getValidationErrors().add("userCheckBox",new
SimpleError(error));
  }
  return getContext().getSourcePageResolution();
  }
  }
return new RedirectResolution("import.action");
}

and here is jsp:


--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Problem with Stripes:param

2015-02-27 Thread Nahid Seidi
Rick,

You're right! It works without doing any filter mapped.

Thanks!
/Nahid

On Fri, Feb 27, 2015 at 1:48 PM, Rick Grashel  wrote:

> Nahid,
>
> Ah, good find by everyone that your server isn't in UTF-8.
>
> If you are using Resin, just put this in your resin configuration file:
>
> utf-8
>
> That should fix the issue without the need for a filter.
>
> -- Rick
>
>
> On Fri, Feb 27, 2015 at 6:15 AM, Nahid Seidi 
> wrote:
>
>> Thank you everyone for your answers. I added the following in web.xml and
>> it works now! But it's also weird to me how Spring MVC affects on encoding!
>>
>> 
>> CharacterEncodingFilter
>>
>> org.springframework.web.filter.CharacterEncodingFilter
>> 
>> encoding
>> UTF-8
>> 
>> 
>> 
>> CharacterEncodingFilter
>> /*
>>   
>>
>> /Nahid
>>
>> On Fri, Feb 27, 2015 at 11:52 AM, Nahid Seidi 
>> wrote:
>>
>>> Hi Gérald
>>>
>>> I'm using Resin. I guess I need to find out how to do the configuration
>>> you sent in resin.
>>>
>>> /Nahid
>>>
>>>
>>> On Friday, February 27, 2015, Gérald Quintana 
>>> wrote:
>>>
>>>> Hello,
>>>>
>>>> If you're using Tomcat:
>>>>
>>>>- Such a filter is provided by Tomcat:
>>>>
>>>> https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/filters/SetCharacterEncodingFilter.html
>>>>- Or you can force Tomcat to use UTF-8 at the Connector level: <
>>>>Connector port="8080" *URIEncoding="UTF-8"*/>
>>>>
>>>> Gérald
>>>>
>>>> 2015-02-27 11:07 GMT+01:00 VANKEISBELCK Remi :
>>>>
>>>>> Hi,
>>>>>
>>>>> I'd say Nestor is right. You app server is probably using platform
>>>>> locale.
>>>>>
>>>>> You probably want this kind of filter :
>>>>>
>>>>> https://github.com/pojosontheweb/woko/blob/develop/core/src/main/java/woko/util/SetCharacterEncodingFilter.java
>>>>>
>>>>> And configure it to use utf-8.
>>>>>
>>>>> Cheers
>>>>>
>>>>> Rémi
>>>>>
>>>>>
>>>>> 2015-02-27 9:42 GMT+01:00 Nahid Seidi :
>>>>>
>>>>>> Rick,
>>>>>>
>>>>>> I already tried the encoding tag, but it doesn't work. As I said, I
>>>>>> don't think the problem is with encoding because as you see in the first
>>>>>> jsp I get 'fname' form an actionbean and then send that to another one.
>>>>>> Since 'fname' is shown correctly in first jsp but not in second jsp so I
>>>>>> don't think it is about encoding. I wonder if there is another way to 
>>>>>> pass
>>>>>> parameters (fname, lname) to the other jsp using something other than
>>>>>> stripes:param ?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Feb 27, 2015 at 1:11 AM, Rick Grashel 
>>>>>> wrote:
>>>>>>
>>>>>>> Nahid,
>>>>>>>
>>>>>>> I've never had a problem with encoding the contents of a parameter.
>>>>>>> Try again with this at the very top of your JSP or the very top of your
>>>>>>> stripes template:
>>>>>>>
>>>>>>> <%@ page contentType="text/html; charset=UTF-8" %>
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>> -- Rick
>>>>>>>
>>>>>>> On Thu, Feb 26, 2015 at 5:27 PM, Nahid Seidi 
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi
>>>>>>>>
>>>>>>>> I am sending some variables from stripes:param to another
>>>>>>>> actionbean in order to show them in another jsp file. The problem is 
>>>

[Stripes-users] Binding actionsBeans correctly

2015-02-27 Thread Nahid Seidi
In following code I am calling a method in 'FirstAction' from
'SecondAction'.

When exception occurs in 'FirstAction' I need the 'getSourcePageResolution'
to get back to 'import.jsp' as the UrlBinding is saying so, but instead, it
gets back to a default error page which I defined in web.xml as following:


500
/WEB-INF/jsp/error.jsp


Here is the code for two actions and one jsp that I'm using

FirstAction.java

@UrlBinding("/example/import.action")
public class FirstAction implements ActionBean {
@DontValidate
public Resolution importTable() throws IOException  {
try {
// do something
} catch(Exception e) {
this.getContext().getValidationErrors().addGlobalError(new
SimpleError(e.getMessage()));
return getContext().getSourcePageResolution();
}
 return new RedirectResolution("/list.action");
}
}

SecondAction.java

public class SecondAction implements ActionBean {
@DefaultHandler
@DontValidate
public Resolution callImportTable() {
return new RedirectResolution (FirstAction.class, "importTable");
}
}

import.jsp





Is there any way to do the binding from 'SecondAction' to 'FirstAction' so
 'getSourcePageResolution' shows the 'import.jsp' instead of 'error.jsp' ?
--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] SessionScope hides Stripes:errors

2015-02-27 Thread Nahid Seidi
Rick,

ImportExcel is a class providing setters and getters.

Here is the cod for jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %>




 


 
 






On Fri, Feb 27, 2015 at 2:44 PM, Rick Grashel  wrote:

> Nahid,
>
> What is "ImportExcel"?  Is that just a class you are building up in a List
> internally?   Seeing the entire piece of code with JSP would help here.
> It's hard to understand the page flow from the code you've provided.
>
> -- Rick
>
> On Fri, Feb 27, 2015 at 7:03 AM, Nahid Seidi 
> wrote:
>
>> I need to use @SessionScope to make a list stay in the page after
>> refreshing, but when I use it, Stripes:error doesn't display error any
>> more. Stripes:error works actually(error is on a field in which user needs
>> to input and if the field is empty, error is showing and user can not
>> submit the form) because the submission is disabled, but it just doesn't
>> show the error message in the page any more. I think there is something
>> with @SessionScope because when I run the code without it all the errors
>> shown in the page. Any Idea of how to fix this?
>>
>> Note: I also tried to use @Wizard(startEvents="event") and it lets errors
>> to be shown but doesn't do anything with saving the list in the page!
>> Here is java code:
>>
>> @SessionScope
>> @UrlBinding("/Student/import.action")
>> public class ImportAction implements ActionBean {
>>
>>   private List importExcel;
>> private String userCheckBox;
>>
>> public Resolution importStudents() throws IOException {
>>
>> try {
>> //Here I put data into importExcel list
>> } catch {}
>>
>>   if (userCheckBox == null) {
>>   if(importExcel.size() > 0) {
>>   for(String error : importExcel) {
>>   this.getContext().getValidationErrors().add("userCheckBox",new
>> SimpleError(error));
>>   }
>>   return getContext().getSourcePageResolution();
>>   }
>>   }
>> return new RedirectResolution("import.action");
>> }
>>
>> and here is jsp:
>>
>> > field="userCheckBox"/>
>>
>>
>>
>> --
>> Dive into the World of Parallel Programming The Go Parallel Website,
>> sponsored
>> by Intel and developed in partnership with Slashdot Media, is your hub
>> for all
>> things parallel software development, from weekly thought leadership
>> blogs to
>> news, videos, case studies, tutorials and more. Take a look and join the
>> conversation now. http://goparallel.sourceforge.net/
>> ___
>> Stripes-users mailing list
>> Stripes-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
>
> --
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> ___
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Binding actionsBeans correctly

2015-02-27 Thread Nahid Seidi
Here is the code:

FirstAction.java

@SessionScope
@UrlBinding("/Student/newImport.action")
public class FirstAction implements ActionBean {
 @SpringBean
private StudentFacade studentFacade;
 private List importExcel;
private String userCheckBox;
 @DefaultHandler
@DontValidate
public Resolution edit() {
return new Forward("/import.jsp");
}

@DontValidate
public Resolution importStudents() throws IOException {

try {
//Here I put data into importExcel list
} catch {}

  if (userCheckBox == null) {
  if(importExcel.size() > 0) {
  for(String error : importExcel) {
  this.getContext().getValidationErrors().add("userCheckBox",new
SimpleError(error));
  }
  return getContext().getSourcePageResolution();
  }
  }

  try {
studentFacade.importStudents(importExcel);
} catch(Exception e) {
this.getContext().getValidationErrors().addGlobalError(new
SimpleError(e.getMessage()));
return getContext().getSourcePageResolution();
}
return new RedirectResolution("import.action");
}
 @DontValidate
public Resolution importTable() throws IOException  {
try {
studentFacade.importStudents(importExcel);
} catch(Exception e) {
this.getContext().getValidationErrors().addGlobalError(new
SimpleError(e.getMessage()));
return getContext().getSourcePageResolution();
}
 return new RedirectResolution("/list.action");
}
}

There are two methods in firstAction (importStudents and importTable) in
which when exception happens in 'importStudent' getSourcePage shows the
'import.jsp' but with the same senario in 'importTable' getSourcePages
shows 'error.jsp'

SecondAction.java

public class SecondAction implements ActionBean  {
private List importExcel;
private String userCheckBox;
 @DefaultHandler
@DontValidate
public Resolution callImportTable() throws IOException {
return new RedirectResolution (FirstAction.class, "importTable");
}

public List getImportExcel() {
return importExcel;
}

public void setImportExcel(List importExcel) {
this.importExcel = importExcel;
}
public String userCheckBox() {
return userCheckBox;
}

public void userCheckBox(String userCheckBox) {
this.userCheckBox = userCheckBox;
}
}

import.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %>




 


 
 










The code is part of a bigger project, so I tried to make it as clear as
possible.

By the way, it didn't work with extending the FirstAction.

/Nahid

On Fri, Feb 27, 2015 at 2:51 PM, Rick Grashel  wrote:

> Nahid,
>
> Again, I can't see all the code you are using, but it looks like you can
> just have SecondAction extend FirstAction:
>
> public class SecondAction extends FirstAction {
> @DefaultHandler
> @DontValidate
> public Resolution callImportTable() {
> return super.importTable();
> }
> }
>
> I can't see all the code you have, so this may or may not work.
>
> -- Rick
>
>
> On Fri, Feb 27, 2015 at 7:41 AM, Nahid Seidi 
> wrote:
>
>> In following code I am calling a method in 'FirstAction' from
>> 'SecondAction'.
>>
>> When exception occurs in 'FirstAction' I need the
>> 'getSourcePageResolution' to get back to 'import.jsp' as the UrlBinding is
>> saying so, but instead, it gets back to a default error page which I
>> defined in web.xml as following:
>>
>> 
>> 500
>> /WEB-INF/jsp/error.jsp
>> 
>>
>> Here is the code for two actions and one jsp that I'm using
>>
>> FirstAction.java
>>
>> @UrlBinding("/example/import.action")
>> public class FirstAction implements ActionBean {
>> @DontValidate
>> public Resolution importTable() throws IOException  {
>> try {
>> // do something
>> } catch(Exception e) {
>> this.getContext().getValidationErrors().addGlobalError(new
>> SimpleError(e.getMessage()));
>> return getContext().getSourcePageResolution();
>> }
>>  return new RedirectResolution("/list.action");
>> }
>> }
>>
>> SecondAction.java
>>
>> public class SecondAction implements ActionBean {
>> @DefaultHandler
>> @DontValidate
>> public Resolution callImportTable() {
>> return new RedirectResolution (FirstActio