SessionScope hides Stripes:errors

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

SessionScope hides Stripes:errors

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> 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:

<stripes:checkbox name="userCheckBox"/>
<stripes:errors field="userCheckBox"/>
<stripes:submit name="importStudents" value="Import"/>

------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: SessionScope hides Stripes:errors

Rick Grashel
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 <[hidden email]> 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> 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:

<stripes:checkbox name="userCheckBox"/>
<stripes:errors field="userCheckBox"/>
<stripes:submit name="importStudents" value="Import"/>

------------------------------------------------------------------------------
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: SessionScope hides Stripes:errors

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" %>

<stripes:layout-render name="/WEB-INF/jsp/layout/default.jsp">
    <stripes:layout-component name="outer-contents">
<stripes:form beanclass="com.example.action.ImportAction">
<tags:labeled label="Overwrite existing data">
<stripes:checkbox name="userCheckBox"/>
</tags:labeled>
<stripes:errors field="userCheckBox"></stripes:errors>
<p>
<stripes:submit name="importStudents" value="Import"/>
</p>
</stripes:form>
</stripes:layout-component>
</stripes:layout-render>

On Fri, Feb 27, 2015 at 2:44 PM, Rick Grashel <[hidden email]> 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 <[hidden email]> 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> 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:

<stripes:checkbox name="userCheckBox"/>
<stripes:errors field="userCheckBox"/>
<stripes:submit name="importStudents" value="Import"/>

------------------------------------------------------------------------------
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
[hidden email]
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
[hidden email]
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users