0

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?

2 Answers 2

1

see the answer in the user group.

Sign up to request clarification or add additional context in comments.

Comments

1

Here is a completely working JQGrid Example in Netbeans 6.9.

EditableSortableSearchableStruts2JqueryGrid

Simply resolve the references and get going.

Instead of directly populating the gridModel do this stuff :

List temp=new ArrayList();

temp.add(12);

temp.add(140);

setGridModel(temp);

2 Comments

Here are few working JQGrid Examples in Netbeans 6.9. [Simple Struts2 Jquery grid][1] [Struts2JQGrid with navigation][2] [Editable Struts2JQGrid][3] [Editable Sortable Searchable Struts2JqueryGrid][4] Simply resolve the references and get going. [1]: ziddu.com/download/13289687/SimpleJQGrid.rar.html [2]: ziddu.com/download/13289688/JQGridWithNavigation.rar.html [3]: ziddu.com/download/13289689/JQEditableGrid.rar.html [4]: ziddu.com/download/13289690/JQGridEditableSearchSort.rar.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.