how to submit a stripes form via Javascript

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

how to submit a stripes form via Javascript

Pankaj Sikka
Hi,

I am new to working with Stripes. I have a dropdown ("show ## recordrs per page") and a paginated table on the JSP page and I want to display as many records per page in this table, as the value selected in the dropdown.

The action bean has a variable "recordsPerPage" and I am not able to figure out a way to set the value of this variable and reload the table, so as to change the number of records that are displayed per page. 

What I did is, I added a <stripes:hidden/> with the name "recordsPerPage" and set the value to be the number of records I want to display. I also added a <stripes:submit> to the same form. The "name" attribute of this submit button is the method name of the action bean I have to call. When I click on this button, I am able to do what I want. But now, I am unable to do it through javascript.  I tried doing Dom.get('changeVarRecordsPerPage').submit(); but that does not fire. I am using YUI.

Basically, what I want is to be able to submit the stripes form on the dropdown selection,without having to add that <stripes:submit>. Please help.


Thanks.


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: how to submit a stripes form via Javascript

Poitras Christian

Hi,

 

The 2 things I would check out first.

1)      Is the name of the submit button visible as a parameter in the Ajax request? If not, Stripes will invoke the default handler of your class instead of the handler you want. Many javascript libraries don’t add parameters that are buttons when transforming the form into URL parameters.

2)      Does the validation fail in your action bean? If validation fails, then your handler will not be invoked and your javascript code may seem to do nothing.

 

 

De : Pankaj Sikka [mailto:[hidden email]]
Envoyé : July-03-14 12:57 PM
À : [hidden email]
Objet : [Stripes-users] how to submit a stripes form via Javascript

 

Hi,

 

I am new to working with Stripes. I have a dropdown ("show ## recordrs per page") and a paginated table on the JSP page and I want to display as many records per page in this table, as the value selected in the dropdown.

The action bean has a variable "recordsPerPage" and I am not able to figure out a way to set the value of this variable and reload the table, so as to change the number of records that are displayed per page. 

What I did is, I added a <stripes:hidden/> with the name "recordsPerPage" and set the value to be the number of records I want to display. I also added a <stripes:submit> to the same form. The "name" attribute of this submit button is the method name of the action bean I have to call. When I click on this button, I am able to do what I want. But now, I am unable to do it through javascript.  I tried doing Dom.get('changeVarRecordsPerPage').submit(); but that does not fire. I am using YUI.

Basically, what I want is to be able to submit the stripes form on the dropdown selection,without having to add that <stripes:submit>. Please help.

 

Thanks.


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: how to submit a stripes form via Javascript

Reuven Gaisin
Hi Pankaj,

It is unclear from your email whether you are trying to use AJAX or do a regular form submit. Either way, you need to specify the event handler by passing in a request parameter since you are not doing button clicks. You can pass-in a request parameter to specify the event handler (i.e. the method name in the action bean) to call in one of the following 2 ways:

1) You can explicitly specify the event handler:

// The event handler method name is reloadTable
_eventName=reloadTable

2) Add request parameter name to request parameter [this is not explicit, Stripes figures out that the parameter name matches an event handling method]
reloadTable=

Now, there are a few ways of passing in the request parameter that you want.  You can add a hidden form field with the event name
<input type="hidden" name="_eventName" value="" />

If this form is *only* going to be used to reload the table then you can just hard-code the hidden form field's value to the reloadTable event name.  However, if you are going to be using the form for other things then you can update the value before each submit.

If you are using AJAX then, with YUI, you can serialize the form and add extra parameters (_eventName)  or just build the query string and/or post parameters and include the _eventName.

Let me know if you have any more questions.

Reuven






On Thu, Jul 3, 2014 at 1:45 PM, Poitras Christian <[hidden email]> wrote:

Hi,

 

The 2 things I would check out first.

1)      Is the name of the submit button visible as a parameter in the Ajax request? If not, Stripes will invoke the default handler of your class instead of the handler you want. Many javascript libraries don’t add parameters that are buttons when transforming the form into URL parameters.

2)      Does the validation fail in your action bean? If validation fails, then your handler will not be invoked and your javascript code may seem to do nothing.

 

 

De : Pankaj Sikka [mailto:[hidden email]]
Envoyé : July-03-14 12:57 PM
À : [hidden email]
Objet : [Stripes-users] how to submit a stripes form via Javascript

 

Hi,

 

I am new to working with Stripes. I have a dropdown ("show ## recordrs per page") and a paginated table on the JSP page and I want to display as many records per page in this table, as the value selected in the dropdown.

The action bean has a variable "recordsPerPage" and I am not able to figure out a way to set the value of this variable and reload the table, so as to change the number of records that are displayed per page. 

What I did is, I added a <stripes:hidden/> with the name "recordsPerPage" and set the value to be the number of records I want to display. I also added a <stripes:submit> to the same form. The "name" attribute of this submit button is the method name of the action bean I have to call. When I click on this button, I am able to do what I want. But now, I am unable to do it through javascript.  I tried doing Dom.get('changeVarRecordsPerPage').submit(); but that does not fire. I am using YUI.

Basically, what I want is to be able to submit the stripes form on the dropdown selection,without having to add that <stripes:submit>. Please help.

 

Thanks.


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users