0

I post a form with just form data(kinds of inputs), and I want to display the values when responsed from tornado server.

And when I use the variable in a template as follows:

<td style="width: 55%">
        <label>Fund:</label>
        <input name="fund" type="text" value="{{ fund }}">
        <span class="help-block"></span>
      </td>

it turns out an error, it is same as Handling an undefined template variable in Tornado.

So the question is how I can get a variable from request like java, eg: reqeust.getAttribute("key"); in jsp, Because I can put some variable in to request through request.setAttribute("key", value);

Anyone can help? Thanks a lot.... And I will do appreciate if some good person provides a link to detailed tornado template doc except the official doc, which I think is too simple on template...

Community
  • 1
  • 1
Eric_Chen
  • 227
  • 1
  • 4
  • 13

1 Answers1

3

I think it can be achieved by add variables in method render.....

For somebody else: If you want to submit your form with kinds of inputs as I did, and you want to redisplay your submitted data in the form, you will have to use the method render in RequestHandler, like:

self.render('display.html', **req_args)

that means you have to put the args(or request parameters) again when rendering your page.

Eric_Chen
  • 227
  • 1
  • 4
  • 13
  • 1
    Are you saying you found an answer to your own question? If so can you elaborate for others with the same question? Otherwise, you can add additional details by [updating your original question](http://stackoverflow.com/questions/13855386/variable-in-tornado-template) instead. – Leigh Dec 14 '12 at 01:55
  • 1
    No, this is an answer...not additional information. I think I can accept it, 'cause I have a test and it fits my need.. – Eric_Chen Dec 14 '12 at 05:39
  • Yep, you can accept your own answer. (Thanks for posting the code. It will help the next guy) – Leigh Dec 15 '12 at 03:23