Passing vars or args with redirect seems a better approach...

Something like that

# Controller
form.process().accepted:
    ...
    redirect(URL(..., args=request.args(...),
vars=dict(var_name=request.vars.var_name))

Richard


On Wed, Feb 5, 2014 at 4:14 PM, Stef Mientki <stef.mien...@gmail.com> wrote:

>  thanks,
>
> I didn't know about "components" will study that in the near future.
> For the moment I've replcaed the url with a auto-commit-checkbox, so I'll
> stay on the same page/controller.
>
> cheers,
> Stef
>
>
> On 05-02-14 10:46, Tim Richardson wrote:
>
> redirect starts a new request.
>
> I suppose your redirect URL can contain args and vars based on what comes
> in (see docs on the URL function), and then it would be up to the
> redirected controller to process them. In other words, you pass state in
> the URL.
> Your controller or view could use these get_vars or args to set form
> elements as you wish, or the view could embed those settings in javascript,
> which then takes effect on page load.
>
> Another option is to use web2py's component. Instead of reloading the
> whole page and creating a new request, the submit actions refresh a
> component in the page which contains the grid or form which has the data
> you want to refresh. In this case, you never leave the page you are on.
> This looks better too, it's very smooth. Read the components chapter in the
> book.
>
>
>
>
> On Monday, 3 February 2014 04:21:44 UTC+11, aapaap wrote:
>>
>> hello,
>>
>> I've a form with checkboxes and radiobuttons.
>> All the checkboxes and radioboxes are auto-commit, i.e. the have an
>> argument
>>     onchange="this.form.submit()"
>>
>> Now this works perfect, as soon as a button is changed, the page is
>> refreshed with a new selection from the database.
>>
>> Now I've some other actions on this form, which are realized by a link.
>>
>> This link points to a "controler" that does some action and then
>> redirects to the orginal form.
>> But now the settings of the checkboxes and radiobuttons is lost,
>> I assume the request and specially the "request.post_vars" ar lost.
>>
>> The "controler" looks like :
>>
>> @auth.requires_login()
>> def Block_Page():
>>    if auth.user.id in Beheerders and request.args :
>>      ID = request.args [0]
>>      db ( db.Knutsels.id == ID ).update ( Approved_Date = None )
>>    redirect ( URL ( Show_Knutselen ))
>>
>> thanks,
>> Stef
>>
>
>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to