Hello Rana!

I thought I'd give you an answer, since I recently implemented a form.... Note 
that I'm not a expert, and other users might have other (better) ideas for 
this...

AFAIK you cannot directly use the default RenderingModel (or 
RenderingModelImpl) if you want to process a form.

If you want the form data, there are 2 ways to go about it:


1.       Create a subclass of RenderingModelImpl (or STKTemplateModel, as the 
case may be)
In the subclass, define Bean-Properties (with public getter und setter methods) 
for the form-fields. So if your form-field is called "foo", write a getFoo() 
and setFoo() method.
Magnolia will automatically call your setFoo() method when the form is posted.
You can access the "foo" value in the template, using ${model.foo} for example.
If you need to process the values, you can override the execute() method of 
RenderingModelImpl --> remember to call return super.execute() at the end.

2.       In an STK template you can use     ctx.getParameter("foo")    to 
access arbitrary parameters.

Note that, AFAIK, the parameters are not checked for you, so be sure to 
implement some validation to prevent SQL-, HTML- or JS-Injection attacks.

As for posting directly to a Model-Class, without using a paragraph or 
template, that would be more complicated to set up. Why not create a paragraph 
within some page that is not normally displayed in the site? Then you can post 
to that paragraph, and it won't get in the way of your webpages.
If this is not what you want, you would probably have to create your own 
module, which provides a URL for the post by way of a "dialog" or "page", or 
uses a filter to pick out the request before normal processing has a chance to 
catch it.
I'd recommend posting to a paragraph or template, this is much simpler to set 
up.

Regards from Vienna,

Richard


Von: [email protected] [mailto:[email protected]] 
Im Auftrag von Rana Singh
Gesendet: Mittwoch, 04. August 2010 14:41
An: Magnolia User-List
Betreff: [magnolia-user] posting form to renderModel

Dear All,

As we are building our templates from scratch, there are many trivial and 
simple questions with maybe easy answers.
Here is one simple question:

How do I post my form to a rendermodel-class?
As we do now is to have a template which has a modelClass-node property, but if 
I do not want to have a template, but just post the form to a renderModel, how 
could this be done?

Best Regards, and thanks for all help.

--
--
Rana Ranjit Singh
Solutions Engineer | +47 413 50 220
Iterate AS | www.iterate.no<http://www.iterate.no>
The Lean Software Development Consultancy

----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to