" />
开发者

How to mention action in httpProxy url when using extJS with Grails

开发者 https://www.devze.com 2023-01-21 10:23 出处:网络
I am trying to integratae my Grails application with extJS. Below is the code in my edit.gsp file. <%@ page import=\"tune.Music\"%>

I am trying to integratae my Grails application with extJS. Below is the code in my edit.gsp file.

<%@ page import="tune.Music"%>

       <script type="text/javascript"> 

       var ds = new Ext.data.Store({
           autoLoad: true,
           proxy: new Ext.data.HttpProxy({
           url: 'http://localhost:8080/tune/music/listData'}),
           reader: new Ext.data.JsonReader({
            results: 'total',
            root:'items',
            id:'id'
           },
           [
                   {name: 'playerId'},
                   {name: 'playerPrice'}

              ]
           )
        });

        var cm = new Ext.grid.ColumnModel([
            {header: "Player Id", width: 70, sortable:true,  dataIndex: 'playerId'},
            {header: "Player Price", width: 90, dataIndex: 'playerPrice'}


        ]);
        //cm.defaultSortable = true;

        // create the grid
        var grid = new Ext.grid.GridPanel({
            ds: ds,
            cm: cm,
            renderTo:'grid-example',
            width:1300,
            height:300
        });
                </script>



</head>
<body>

    <div class="body">
    <!--<g:javascript library="examples"/>-->
    <!-- EXAMPLES -->
    <h1>Ext Grid</h1>



     <div id="grid-example"></div>


    </div>

</body>

My controller action:

def list={ }

def listData = { def session = sessionFactory.getCurrentSession() def result = session.createSQLQuery("select player_id from w.music where player_id=('530AS')").list(); def tuneInstance开发者_StackOverflow中文版List = new ArrayList() result.each { def tune = new Tune() tune.playerId = it tune.playerPrice = "100" tuneInstanceList.add(tune) } def listResult = [total: tunInstanceList.size(), items: tunInstanceList] render listResult as JSON; }

The above code works for me.

However, This works in my development environment. If I run this in another env it doesnt work because of the url that I have hardcoded here viz url: 'http://localhost:8080/tune/music/listData'.

One of the options is to use gsparse. However, i would like to mention a relative urlPath here if thats possible. What do I replace my urlPath with so that the right action is called even in other environments.

Thanks!


replaced the HttpProxy url as

url: '/tune/music/listData' and it worked.

Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消