include / render ftl file or screen in a java script file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

include / render ftl file or screen in a java script file

Robert Gan
Hey,

Im doing an Ajax database manipulation. After Ajax succeed I want to replace a div-container (referenced with its ID) with the content of an ftl file. THe background is,that I want to update the data in the div-container.

I couldnt get it run with screens.render(../xy.ftl)

I tried it with the .load method (jquery) like that:

$(#div-container-ID).load(../xy.ftl), but it does not work. WIth above named rendering it had not worked either.

Do anyone has an idea? I do this to avoid a complete site-reload.
Reply | Threaded
Open this post in threaded view
|

Re: include / render ftl file or screen in a java script file

Rajbir Saini
Robert,

You cant load a ftl file like this. JavaScript is a client side
technology and Freemarker runs on server side. What you need inside your
JQuery is  HTML fragment and therefore to get the contents of an HTML
file, create a request map in controller, pass it to the view map, and
then the screen widget. Within your screen, include the FTL file. This
is same as your calls without Ajax. Only difference would be, do not
include the decorator in your Ajax screen as it will show the complete page.

One you receive the response in your JQuery success callback, replace
the contents within you DIV with the contents received form server using
something like $(#your div id).html(data).

Thanks,

Raj

On Monday 16 April 2012 01:52 AM, Robert G. wrote:

> Hey,
>
> Im doing an Ajax database manipulation. After Ajax succeed I want to replace
> a div-container (referenced with its ID) with the content of an ftl file.
> THe background is,that I want to update the data in the div-container.
>
> I couldnt get it run with screens.render(../xy.ftl)
>
> I tried it with the .load method (jquery) like that:
>
> $(#div-container-ID).load(../xy.ftl), but it does not work. WIth above named
> rendering it had not worked either.
>
> Do anyone has an idea? I do this to avoid a complete site-reload.
>
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/include-render-ftl-file-or-screen-in-a-java-script-file-tp4559817p4559817.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>

Reply | Threaded
Open this post in threaded view
|

Re: include / render ftl file or screen in a java script file

Robert Gan
wonderful!!! Thanks :) and thanks for the declaration concerning the technologies!

Greetings

Robert
Reply | Threaded
Open this post in threaded view
|

Re: include / render ftl file or screen in a java script file

Robert Gan
just tested, works perfectly!
Reply | Threaded
Open this post in threaded view
|

Re: include / render ftl file or screen in a java script file

Rajbir Saini
Excellent. :-)

On Monday 16 April 2012 08:14 AM, Robert G. wrote:
> just tested, works perfectly!
>
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/include-render-ftl-file-or-screen-in-a-java-script-file-tp4559817p4560420.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>