views:

285

answers:

1

Hi I'm using Java at the core backend and JSP pages as GUI frontend. and also I'm using Struts2 to connect JSP Pages to my Java Core.

struts2 jQuery plugin provides jquery capabilities as struts tags. see the showcase here:

now I wanna load 2 very simple 1 columned rows into the grid provided by jQuery Plugin. I've got just this tag in my index.jsp:

<s:url id="remoteurl" action="jsontable"/>
<sjg:grid
    id="gridtable"
    caption="Stocks Examples"
    dataType="json"
    href="%{remoteurl}"
    pager="true"
    gridModel="gridModel"

    rowNum="2"
    rownumbers="true"
>
    <sjg:gridColumn name="id" index="id" title="ID" formatter="integer" sortable="false"/>
</sjg:grid> 

my Struts Action is:

public String execute() {

            // Count Rows (select count(*) from costumer)
            records = 2;
            rows=2;
            // Your logic to search and select the required data.
            gridModel = new ArrayList<Integer>();
            gridModel.add(15);
            gridModel.add(80);
            // calculate the total pages for the query
            total = (int) Math.ceil((double) records / (double) rows);
            System.out.println("I'm a JSON Action ");
            return SUCCESS;
    }

    public String getJSON() {
            return execute();
    } 

Finally the struts XML Config file:

<struts>
  <constant name="struts.enable.DynamicMethodInvocation" value="true" /

  <constant name="struts.devMode" value="false" />
  <constant name="struts.custom.i18n.resources"
value="ApplicationResources" />

  <package name="default" extends="struts-default,json-default" >

  <action name="jsontable" class="strutsAction.JsonTable" >
      <result type="json" name="success"></result>
  </action>

  </package>
</struts>

I expect to see two rows in my one columned grid representing the values: 15 and 80 as I set them in the Struts Action. But What I get is two rows, both 0

any ideas?

+1  A: 

see the answer in the user group.

jogep