Other things to consider...

Unless the form submission results in creating/updating a record, you might 
want to do a GET instead of a POST request.

Instead of a single component with a form and some data to display, 
consider two separate components -- one with the form, and one to display 
the data. When the form is submitted, upon completion of the Ajax request, 
you can have the second component load the data, setting it to reload 
repeatedly. Your view might look something like:

{{=LOAD('performance_matrix', 'form.load', ajax=True)}}

<div id="data"></div>

Then in the form action:

def form():
    ...
    if request.vars.some_field:
        data_url = URL('performance_matrix', 'data.load',
                       vars=dict(some_field=request.vars.some_field))
        response.js = '$.web2py.component("%s", "data", timeout=1000*60, 
times="infinity")' % data_url
    return dict(form=form)

Rather than handling everything via the index() function, have separate 
functions for dealing with the form and generating the data output. When 
the form is submitted, the above triggers Javascript to load the relevant 
data in the "#data" div on the page. Because the value of the field is 
encoded in the query string of the "#data" component's URL, every time it 
reloads, it will display the same data (until the form is submitted again 
and the "#data" component is overwritten with a new one).

Anthony

On Monday, February 16, 2015 at 3:20:27 PM UTC-5, Anthony wrote:
>
> You should probably store the state in the session, so after the initial 
> form submission, re-loads can read the values from the session.
>
> Anthony
>
> On Monday, February 16, 2015 at 11:23:07 AM UTC-5, Boris Aramis Aguilar 
> Rodríguez wrote:
>>
>> Hi, currently I'm using LOAD and components on a project. The problem is 
>> that when using a timeout for auto-reloading the component then the current 
>> view state is lost, let me explain:
>>
>> 1. A controller called performance_matrix.py has a method index(); that 
>> method receives request.vars and depending on received variable x it 
>> displays a different type of data.
>>
>> 2. The view performance_matrix/index.html is quite simple, because it has 
>> just the LOAD inside of it to load the component that displays a matrix 
>> depending on an x variable.
>>
>> {{extend 'layout.html'}}
>> {{block center}}
>> {{=LOAD('performance_matrix','index.load',ajax=True, times = "infinity", 
>> timeout=1000*60)}}
>> {{end}}
>>
>> 3. The file performance_matrix/index.load contains the view of the 
>> component, it has a form that when you change values on it it makes a POST 
>> to the server with the new x variable that changes what the view displays.
>>
>> 4. The problem is, that when timeout within the load happends, then 
>> requested variable x is lost so the state of the displayed view gets back 
>> to default I don't want this behavior; i want the timeout to happend and 
>> send whatever vars I currently have in the state of the component.
>>
>> Any help i would appreciate it.
>>
>> Thanks!
>>
>

-- 
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/d/optout.

Reply via email to