Grails - J2ee integration

View: New views
15 Messages — Rating Filter:   Alert me  

Grails - J2ee integration

by Ruchi Singhal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render a grails app(ajax based).I  could achieve this by simply using an iFrame,but I dodnot wish to use it for performance reasons.Is there any other way out

Please note that the J2ee app and grails app are on 2 different servers.

Any pointers would be very helpful

Thanks In Advance
Regards,
Ruchi

Re: Grails - J2ee integration

by Lucas Teixeira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can do this asking via ajax to the grails app.
But since apps are in different servers, you'll need to set up some apache in front of them, so the grails app have to respond in the same domain from the other one. otherwise you won't get this working (crossdomain vunerability).

[]s,


Lucas Frare Teixeira .·.
- lucastex@...
- blog.lucastex.com
- twitter.com/lucastex


On Fri, Jul 3, 2009 at 2:24 AM, Ruchi Singhal <rsinghal@...> wrote:

Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

Please note that the J2ee app and grails app are on 2 different servers.

Any pointers would be very helpful

Thanks In Advance
Regards,
Ruchi
--
View this message in context: http://www.nabble.com/Grails---J2ee-integration-tp24317781p24317781.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




RE: Grails - J2ee integration

by Ruchi Singhal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Yes are doing ajax, but how can we render a gsp from a grails app inside a  div of a jsp f a j2ee app?

 

From: Lucas F. A. Teixeira [mailto:lucastex@...]
Sent: 03 July 2009 16:15
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

You can do this asking via ajax to the grails app.
But since apps are in different servers, you'll need to set up some apache in front of them, so the grails app have to respond in the same domain from the other one. otherwise you won't get this working (crossdomain vunerability).

[]s,


Lucas Frare Teixeira .·.
- lucastex@...
- blog.lucastex.com
- twitter.com/lucastex

On Fri, Jul 3, 2009 at 2:24 AM, Ruchi Singhal <rsinghal@...> wrote:


Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

Please note that the J2ee app and grails app are on 2 different servers.

Any pointers would be very helpful

Thanks In Advance
Regards,
Ruchi
--
View this message in context: http://www.nabble.com/Grails---J2ee-integration-tp24317781p24317781.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email

 


Re: Grails - J2ee integration

by Felipe Rodrigues 02 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The Ajax call will only see the rendered html. The GSP is parsed an server level, so you don't need to care about that.

Ruchi Singhal wrote:

Yes are doing ajax, but how can we render a gsp from a grails app inside a  div of a jsp f a j2ee app?

 

From: Lucas F. A. Teixeira [lucastex@...]
Sent: 03 July 2009 16:15
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

You can do this asking via ajax to the grails app.
But since apps are in different servers, you'll need to set up some apache in front of them, so the grails app have to respond in the same domain from the other one. otherwise you won't get this working (crossdomain vunerability).

[]s,


Lucas Frare Teixeira .·.
- lucastex@...
- blog.lucastex.com
- twitter.com/lucastex

On Fri, Jul 3, 2009 at 2:24 AM, Ruchi Singhal <rsinghal@...> wrote:


Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

Please note that the J2ee app and grails app are on 2 different servers.

Any pointers would be very helpful

Thanks In Advance
Regards,
Ruchi
--
View this message in context: http://www.nabble.com/Grails---J2ee-integration-tp24317781p24317781.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email

 

--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Felipe Rodrigues
http://www.fratech.net

Re: Grails - J2ee integration

by Lucas Teixeira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

exactly

Lucas Frare Teixeira .·.
- lucastex@...
- blog.lucastex.com
- twitter.com/lucastex


On Fri, Jul 3, 2009 at 10:33 AM, Felipe Rodrigues <felipero.maillist@...> wrote:
The Ajax call will only see the rendered html. The GSP is parsed an server level, so you don't need to care about that.


Ruchi Singhal wrote:

Yes are doing ajax, but how can we render a gsp from a grails app inside a  div of a jsp f a j2ee app?

 

From: Lucas F. A. Teixeira [lucastex@...]
Sent: 03 July 2009 16:15
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

You can do this asking via ajax to the grails app.
But since apps are in different servers, you'll need to set up some apache in front of them, so the grails app have to respond in the same domain from the other one. otherwise you won't get this working (crossdomain vunerability).

[]s,


Lucas Frare Teixeira .·.
- lucastex@...
- blog.lucastex.com
- twitter.com/lucastex

On Fri, Jul 3, 2009 at 2:24 AM, Ruchi Singhal <rsinghal@...> wrote:


Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

Please note that the J2ee app and grails app are on 2 different servers.

Any pointers would be very helpful

Thanks In Advance
Regards,
Ruchi
--
View this message in context: http://www.nabble.com/Grails---J2ee-integration-tp24317781p24317781.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email

 

--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email


Re: Grails - J2ee integration

by tomas lin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can also just fetch the generated webapp and pass the html to your
jsp page as a string.

http://www.javapractices.com/topic/TopicAction.do?Id=147

This does give your server a performance hit every time the remote
page is accessed, but eliminates a lot of setup and deployment
problems.



On Fri, Jul 3, 2009 at 11:45 AM, Lucas F. A. Teixeira<lucastex@...> wrote:

> You can do this asking via ajax to the grails app.
> But since apps are in different servers, you'll need to set up some apache
> in front of them, so the grails app have to respond in the same domain from
> the other one. otherwise you won't get this working (crossdomain
> vunerability).
>
> []s,
>
>
> Lucas Frare Teixeira .·.
> - lucastex@...
> - blog.lucastex.com
> - twitter.com/lucastex
>
>
> On Fri, Jul 3, 2009 at 2:24 AM, Ruchi Singhal <rsinghal@...>
> wrote:
>>
>> Hi All,
>>
>> I wish to do very simple thing -
>>
>> In one of the divs in a JSP of my existing J2ee application I wish to
>> render
>> a grails app(ajax based).I  could achieve this by simply using an
>> iFrame,but
>> I dodnot wish to use it for performance reasons.Is there any other way out
>>
>> Please note that the J2ee app and grails app are on 2 different servers.
>>
>> Any pointers would be very helpful
>>
>> Thanks In Advance
>> Regards,
>> Ruchi
>> --
>> View this message in context:
>> http://www.nabble.com/Grails---J2ee-integration-tp24317781p24317781.html
>> Sent from the grails - user mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



RE: Grails - J2ee integration

by Ruchi Singhal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Can u give an example how I can embed the grails app in a jsp div with ajax call u just mentioned?

 

TIA,

 

Ruchi

 

From: Lucas F. A. Teixeira [mailto:lucastex@...]
Sent: 03 July 2009 19:31
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

exactly

Lucas Frare Teixeira .·.
- lucastex@...
- blog.lucastex.com
- twitter.com/lucastex

On Fri, Jul 3, 2009 at 10:33 AM, Felipe Rodrigues <felipero.maillist@...> wrote:

The Ajax call will only see the rendered html. The GSP is parsed an server level, so you don't need to care about that.



Ruchi Singhal wrote:

Yes are doing ajax, but how can we render a gsp from a grails app inside a  div of a jsp f a j2ee app?

 

From: Lucas F. A. Teixeira [lucastex@...]
Sent: 03 July 2009 16:15
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

You can do this asking via ajax to the grails app.
But since apps are in different servers, you'll need to set up some apache in front of them, so the grails app have to respond in the same domain from the other one. otherwise you won't get this working (crossdomain vunerability).

[]s,


Lucas Frare Teixeira .·.
- lucastex@...
- blog.lucastex.com
- twitter.com/lucastex

On Fri, Jul 3, 2009 at 2:24 AM, Ruchi Singhal <rsinghal@...> wrote:


Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

Please note that the J2ee app and grails app are on 2 different servers.

Any pointers would be very helpful

Thanks In Advance
Regards,
Ruchi
--
View this message in context: http://www.nabble.com/Grails---J2ee-integration-tp24317781p24317781.html
Sent from the grails - user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email

 

--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

 


Re: Grails - J2ee integration

by JuliusH :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

JSP

<tr>
 <td>
  <select onchange="jQuery.ajax({
    url: '/ajax/optfoo',
    data: 'optid=' + this.value,
    cache: false,
    success: function(html) {
    jQuery('#models').html(html);
    }});" >

    <option></option>
    <option value="1">OPT_A</option>
    <option value="2">OPT_B</option>
    <option value="3">OPT_C</option>
  </select>
 </td>
</tr>

<tr>
 <td>
  <label for="model"> &nbsp; Model &nbsp; </label>* &nbsp; : &nbsp;
 </td>
 <td>
  <div id="models">

  </div>
 </td>
</tr>


Grails

def optfoo = {
  def model = optid.findByoptId(params.optid)

  render model ..... // Check Grails Doc for Render as HTML/XML/JSON .....
}


Cheers,

Julius


On 06 Jul , 2009, at 12:18 , Ruchi Singhal wrote:


Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out



RE: Grails - J2ee integration

by Ruchi Singhal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

This example would work only if the jsp and the gsp are in the same domain ,but if they are not then how would this work??

i.e if the jsp is a  different server and the grails app is on some other one this won’t work rt???

 

From: Julius Huang [mailto:juliushuang@...]
Sent: 06 July 2009 11:50
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

Hi,

 

JSP

 

<tr>

 <td>

  <select onchange="jQuery.ajax({

    url: '/ajax/optfoo',

    data: 'optid=' + this.value,

    cache: false,

    success: function(html) {

    jQuery('#models').html(html);

    }});" >

 

    <option></option>

    <option value="1">OPT_A</option>

    <option value="2">OPT_B</option>

    <option value="3">OPT_C</option>

  </select>

 </td>

</tr>

 

<tr>

 <td>

  <label for="model"> &nbsp; Model &nbsp; </label>* &nbsp; : &nbsp;

 </td>

 <td>

  <div id="models">

 

  </div>

 </td>

</tr>

 

 

Grails

 

def optfoo = {

  def model = optid.findByoptId(params.optid)

 

  render model ..... // Check Grails Doc for Render as HTML/XML/JSON .....

}

 

 

Cheers,

 

Julius

 

 

On 06 Jul , 2009, at 12:18 , Ruchi Singhal wrote:




Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

 


Re: Grails - J2ee integration

by Stephen Souness :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You could have your JSP webapp act as a proxy, accepting an AJAX request from the browser, then making a request to the Grails webapp, processing the response and forwarding that back to the browser.

Browser -> J2EE app -> Grails app
Browser <- J2EE app <- Grails app

this would get complicated if it required any cookies for the interaction with the Grails app.


--
Stephen Souness

Re: Grails - J2ee integration

by Felipe Rodrigues 02 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

They don't have to be in the same domain. To this work on different domains you should include the hostname on the url.

You should check JQuery and Prototype and maybe run a try?


Ruchi Singhal wrote:

This example would work only if the jsp and the gsp are in the same domain ,but if they are not then how would this work??

i.e if the jsp is a  different server and the grails app is on some other one this won’t work rt???

 

From: Julius Huang [juliushuang@...]
Sent: 06 July 2009 11:50
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

Hi,

 

JSP

 

<tr>

 <td>

  <select onchange="jQuery.ajax({

    url: '/ajax/optfoo',

    data: 'optid=' + this.value,

    cache: false,

    success: function(html) {

    jQuery('#models').html(html);

    }});" >

 

    <option></option>

    <option value="1">OPT_A</option>

    <option value="2">OPT_B</option>

    <option value="3">OPT_C</option>

  </select>

 </td>

</tr>

 

<tr>

 <td>

  <label for="model"> &nbsp; Model &nbsp; </label>* &nbsp; : &nbsp;

 </td>

 <td>

  <div id="models">

 

  </div>

 </td>

</tr>

 

 

Grails

 

def optfoo = {

  def model = optid.findByoptId(params.optid)

 

  render model ..... // Check Grails Doc for Render as HTML/XML/JSON .....

}

 

 

Cheers,

 

Julius

 

 

On 06 Jul , 2009, at 12:18 , Ruchi Singhal wrote:




Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

 

--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
Felipe Rodrigues
http://www.fratech.net

RE: Grails - J2ee integration

by Ruchi Singhal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

It doesn’t work if they are in different domains.I am getting the following exception even if my apps are running locally on my system but 2 differnt servers--

access to restricted uri denied code 1012

 

From: Felipe Rodrigues [mailto:felipero.maillist@...]
Sent: 07 July 2009 19:33
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

They don't have to be in the same domain. To this work on different domains you should include the hostname on the url.

You should check JQuery and Prototype and maybe run a try?


Ruchi Singhal wrote:

This example would work only if the jsp and the gsp are in the same domain ,but if they are not then how would this work??

i.e if the jsp is a  different server and the grails app is on some other one this won’t work rt???

 

From: Julius Huang [juliushuang@...]
Sent: 06 July 2009 11:50
To: user@...
Subject: Re: [grails-user] Grails - J2ee integration

 

Hi,

 

JSP

 

<tr>

 <td>

  <select onchange="jQuery.ajax({

    url: '/ajax/optfoo',

    data: 'optid=' + this.value,

    cache: false,

    success: function(html) {

    jQuery('#models').html(html);

    }});" >

 

    <option></option>

    <option value="1">OPT_A</option>

    <option value="2">OPT_B</option>

    <option value="3">OPT_C</option>

  </select>

 </td>

</tr>

 

<tr>

 <td>

  <label for="model"> &nbsp; Model &nbsp; </label>* &nbsp; : &nbsp;

 </td>

 <td>

  <div id="models">

 

  </div>

 </td>

</tr>

 

 

Grails

 

def optfoo = {

  def model = optid.findByoptId(params.optid)

 

  render model ..... // Check Grails Doc for Render as HTML/XML/JSON .....

}

 

 

Cheers,

 

Julius

 

 

On 06 Jul , 2009, at 12:18 , Ruchi Singhal wrote:





Hi All,

I wish to do very simple thing -

In one of the divs in a JSP of my existing J2ee application I wish to render
a grails app(ajax based).I  could achieve this by simply using an iFrame,but
I dodnot wish to use it for performance reasons.Is there any other way out

 

--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email


Re: Grails - J2ee integration

by JuliusH :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

My previous post was to answer,
"Can u give an example how I can embed the grails app in a jsp div  
with ajax call u just mentioned?"

As others have mentioned the "Cross Domain With AJAX Issue" need to  
be address to make it work.

I apologize for not answer Both of the questions.
I have a important meeting in a few days.
I will try write an workable example by the end of the week.
(I also need this in the near future)

Proposed solution from Google is like this (one out of many),
http://ajaxian.com/archives/jsonp-json-with-padding

Here is what I would do,
1. Create a Grails App to render JASONP instead of HTML
    (// Check Grails Doc for Render as HTML/XML/JSON .....)
    http://www.pathf.com/blogs/2008/02/grails-and-json/
2. Rework Javascript using JSONP,
    I have no specific one in mind, jQuery, Prototype, Dojo all seem ok

If any one has insight / suggestion / experience / recommendation,
I would love to hear it before I spend or waste too much time.
Feel free to send me mail off the list ...

Julius



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Grails - J2ee integration

by bald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I did exactly that testing GAE and a  ~static php website

In legacy app:

        function getAppEngineData(p){
                $.getJSON("http://xxxengine.appspot.com/product/listJson?node="+p+"&callback=?",
                        function(data){
                                data.value; // data is the json loaded in jsonp reply
                        }
                )

        }
        if($_GET['testappengine']){
                ?>    
                <form>
                 <select onchange="getAppEngineData($(this).val())">
                        <option value="type1">Type 1</option>
                        <option value="type2">Type 2</option>
                        <option value="type3">Type 3</option>
                        </select>  
                </form>
                <?
        }

In grails app:

    def listJson = {
        params.max = 1000

        def query = persistenceManager.newQuery( Product )

        def productInstanceList
        if(params.node){
            query.setFilter("node == nodeParam")
            query.declareParameters("String nodeParam")

            productInstanceList = query.execute(params.node)

        } else {
             productInstanceList = query.execute()
        }

        render "${'listProducts'}(${map as JSON})"
    }




JuliusH wrote:
Hi,

My previous post was to answer,
"Can u give an example how I can embed the grails app in a jsp div  
with ajax call u just mentioned?"

As others have mentioned the "Cross Domain With AJAX Issue" need to  
be address to make it work.

I apologize for not answer Both of the questions.
I have a important meeting in a few days.
I will try write an workable example by the end of the week.
(I also need this in the near future)

Proposed solution from Google is like this (one out of many),
http://ajaxian.com/archives/jsonp-json-with-padding

Here is what I would do,
1. Create a Grails App to render JASONP instead of HTML
    (// Check Grails Doc for Render as HTML/XML/JSON .....)
    http://www.pathf.com/blogs/2008/02/grails-and-json/
2. Rework Javascript using JSONP,
    I have no specific one in mind, jQuery, Prototype, Dojo all seem ok

If any one has insight / suggestion / experience / recommendation,
I would love to hear it before I spend or waste too much time.
Feel free to send me mail off the list ...

Julius



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Re: Grails - J2ee integration

by bald :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I forgot the other javascript function:

        function listProducts(datos){
                var lst = datos.lst
                var max = lst.length

                var table = $('#appengineData').html("<table id='productsContent'></table>").children('table')

                for(var i=0; i<max;++i){    

                    table.append("<tr class='prodcutOdd'></tr>")
                    var tr =  $('#appengineData #productsContent tr:last-child')
                    tr.append("<td><IMMG class='tooltip' src='" + lst[i].imgSrc + "'/></td>")
                    tr.append("<td><em>" + lst[i].name + "</em></td>")
                }
               

        }


Notice the callback param in the url request.
I also forgot a line before the render in the controller:
map.put('lst', productInstanceList)
render "${'listProducts'}(${map as JSON})"






bald wrote:
Hi,

I did exactly that testing GAE and a  ~static php website

In legacy app:

        function getAppEngineData(p){
                $.getJSON("http://xxxengine.appspot.com/product/listJson?node="+p+"&callback=?",
                        function(data){
                                data.value; // data is the json loaded in jsonp reply
                        }
                )

        }
        if($_GET['testappengine']){
                ?>    
                <form>
                 <select onchange="getAppEngineData($(this).val())">
                        <option value="type1">Type 1</option>
                        <option value="type2">Type 2</option>
                        <option value="type3">Type 3</option>
                        </select>  
                </form>
                <?
        }

In grails app:

    def listJson = {
        params.max = 1000

        def query = persistenceManager.newQuery( Product )

        def productInstanceList
        if(params.node){
            query.setFilter("node == nodeParam")
            query.declareParameters("String nodeParam")

            productInstanceList = query.execute(params.node)

        } else {
             productInstanceList = query.execute()
        }

        render "${'listProducts'}(${map as JSON})"
    }