clearing form values before ForwardResolution

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

clearing form values before ForwardResolution

krick
I have a situation where I'm submitting a form with search parameters, performing a database search, and forwarding to the same page with the results of the search displayed in a table beneath the form input fields with all the search parameters.  Pretty standard stuff, really.

The problem I'm having is that there's a radio button group (and possibly a few other fields) on the form that I would like to clear after a successful search but I can't figure out how to do it.  Setting the various values to null in the ActionBean before returning the ForwardResolution isn't working.

I also tried doing this, which didn't work either...

getContext().getRequest().setAttribute("assignToSelection", null);

What's the correct way to clear form values in the action bean?

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: clearing form values before ForwardResolution

Andy Patil
Please check
Hope that helps.
Regards
Andy

Sent from my iPhone

On Jul 22, 2015, at 11:14 AM, William Krick <[hidden email]> wrote:

I have a situation where I'm submitting a form with search parameters, performing a database search, and forwarding to the same page with the results of the search displayed in a table beneath the form input fields with all the search parameters.  Pretty standard stuff, really.

The problem I'm having is that there's a radio button group (and possibly a few other fields) on the form that I would like to clear after a successful search but I can't figure out how to do it.  Setting the various values to null in the ActionBean before returning the ForwardResolution isn't working.

I also tried doing this, which didn't work either...

getContext().getRequest().setAttribute("assignToSelection", null);

What's the correct way to clear form values in the action bean?
------------------------------------------------------------------------------
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: clearing form values before ForwardResolution

Rick Grashel
In reply to this post by krick
Hi William,

All you should need to do is just set the actual variable to null in the action bean before you return the resolution.

So let's say the name of the control on the search form was "firstName".  That means that in the event handler method, you would have this line of code:

this.firstName = null;
return new ForwardResolution( "/whatever_page.jsp" );

If it is a nested property on a first class object, then you can do something like this:

searchCriteria.setFirstName( null );
return new ForwardResolution( "/whatever_page.jsp" );

That should do what you are looking for.  Hope this helps.

-- Rick



On Wed, Jul 22, 2015 at 10:14 AM, William Krick <[hidden email]> wrote:
I have a situation where I'm submitting a form with search parameters, performing a database search, and forwarding to the same page with the results of the search displayed in a table beneath the form input fields with all the search parameters.  Pretty standard stuff, really.

The problem I'm having is that there's a radio button group (and possibly a few other fields) on the form that I would like to clear after a successful search but I can't figure out how to do it.  Setting the various values to null in the ActionBean before returning the ForwardResolution isn't working.

I also tried doing this, which didn't work either...

getContext().getRequest().setAttribute("assignToSelection", null);

What's the correct way to clear form values in the action bean?

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: clearing form values before ForwardResolution

krick
@Andy
This is an existing large project in a production environment.  So I can't change the population strategy at this point.  The risk of introducing new and exciting bugs it too great.  One of the comments on StackOverflow suggests using RedirectResolution instead of ForwardResolution but I'm not sure if that's a viable option given the existing code I'm modifying.

@Rick
I've already tried doing exactly as you suggest, setting the value to null, but it doesn't work.

On Wed, Jul 22, 2015 at 11:45 AM, Rick Grashel <[hidden email]> wrote:
Hi William,

All you should need to do is just set the actual variable to null in the action bean before you return the resolution.

So let's say the name of the control on the search form was "firstName".  That means that in the event handler method, you would have this line of code:

this.firstName = null;
return new ForwardResolution( "/whatever_page.jsp" );

If it is a nested property on a first class object, then you can do something like this:

searchCriteria.setFirstName( null );
return new ForwardResolution( "/whatever_page.jsp" );

That should do what you are looking for.  Hope this helps.

-- Rick



On Wed, Jul 22, 2015 at 10:14 AM, William Krick <[hidden email]> wrote:
I have a situation where I'm submitting a form with search parameters, performing a database search, and forwarding to the same page with the results of the search displayed in a table beneath the form input fields with all the search parameters.  Pretty standard stuff, really.

The problem I'm having is that there's a radio button group (and possibly a few other fields) on the form that I would like to clear after a successful search but I can't figure out how to do it.  Setting the various values to null in the ActionBean before returning the ForwardResolution isn't working.

I also tried doing this, which didn't work either...

getContext().getRequest().setAttribute("assignToSelection", null);

What's the correct way to clear form values in the action bean?

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: clearing form values before ForwardResolution

Rick Grashel
William,

What population strategy are you using?  That's definitely going to drive the method for clearing out bean fields.

-- Rick

On Wed, Jul 22, 2015 at 11:54 AM, William Krick <[hidden email]> wrote:
@Andy
This is an existing large project in a production environment.  So I can't change the population strategy at this point.  The risk of introducing new and exciting bugs it too great.  One of the comments on StackOverflow suggests using RedirectResolution instead of ForwardResolution but I'm not sure if that's a viable option given the existing code I'm modifying.

@Rick
I've already tried doing exactly as you suggest, setting the value to null, but it doesn't work.

On Wed, Jul 22, 2015 at 11:45 AM, Rick Grashel <[hidden email]> wrote:
Hi William,

All you should need to do is just set the actual variable to null in the action bean before you return the resolution.

So let's say the name of the control on the search form was "firstName".  That means that in the event handler method, you would have this line of code:

this.firstName = null;
return new ForwardResolution( "/whatever_page.jsp" );

If it is a nested property on a first class object, then you can do something like this:

searchCriteria.setFirstName( null );
return new ForwardResolution( "/whatever_page.jsp" );

That should do what you are looking for.  Hope this helps.

-- Rick



On Wed, Jul 22, 2015 at 10:14 AM, William Krick <[hidden email]> wrote:
I have a situation where I'm submitting a form with search parameters, performing a database search, and forwarding to the same page with the results of the search displayed in a table beneath the form input fields with all the search parameters.  Pretty standard stuff, really.

The problem I'm having is that there's a radio button group (and possibly a few other fields) on the form that I would like to clear after a successful search but I can't figure out how to do it.  Setting the various values to null in the ActionBean before returning the ForwardResolution isn't working.

I also tried doing this, which didn't work either...

getContext().getRequest().setAttribute("assignToSelection", null);

What's the correct way to clear form values in the action bean?

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: clearing form values before ForwardResolution

krick
I believe the app is using the DefaultPopulationStrategy except for a few pages that are annotated with...

@CustomPopulationStrategy(BeanFirstPopulationStrategy.class)

On Wed, Jul 22, 2015 at 1:00 PM, Rick Grashel <[hidden email]> wrote:
William,

What population strategy are you using?  That's definitely going to drive the method for clearing out bean fields.

-- Rick

On Wed, Jul 22, 2015 at 11:54 AM, William Krick <[hidden email]> wrote:
@Andy
This is an existing large project in a production environment.  So I can't change the population strategy at this point.  The risk of introducing new and exciting bugs it too great.  One of the comments on StackOverflow suggests using RedirectResolution instead of ForwardResolution but I'm not sure if that's a viable option given the existing code I'm modifying.

@Rick
I've already tried doing exactly as you suggest, setting the value to null, but it doesn't work.

On Wed, Jul 22, 2015 at 11:45 AM, Rick Grashel <[hidden email]> wrote:
Hi William,

All you should need to do is just set the actual variable to null in the action bean before you return the resolution.

So let's say the name of the control on the search form was "firstName".  That means that in the event handler method, you would have this line of code:

this.firstName = null;
return new ForwardResolution( "/whatever_page.jsp" );

If it is a nested property on a first class object, then you can do something like this:

searchCriteria.setFirstName( null );
return new ForwardResolution( "/whatever_page.jsp" );

That should do what you are looking for.  Hope this helps.

-- Rick



On Wed, Jul 22, 2015 at 10:14 AM, William Krick <[hidden email]> wrote:
I have a situation where I'm submitting a form with search parameters, performing a database search, and forwarding to the same page with the results of the search displayed in a table beneath the form input fields with all the search parameters.  Pretty standard stuff, really.

The problem I'm having is that there's a radio button group (and possibly a few other fields) on the form that I would like to clear after a successful search but I can't figure out how to do it.  Setting the various values to null in the ActionBean before returning the ForwardResolution isn't working.

I also tried doing this, which didn't work either...

getContext().getRequest().setAttribute("assignToSelection", null);

What's the correct way to clear form values in the action bean?

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users