1

I am creating a grid in my JSP something like below

   <sjg:grid gridModel="gridModel"  
          ---- other options -- >


   </sjg:grid>
 

In my struts.xml I am giving this action configuration

    <action name = "jsonAction" calss == "Action class" method = "methodName" >
      <interceptor-ref name="modelDriven" />
       <interceptor-ref name="basicStack" />
     <result name="success" type="json" >
        </result>
     </action>

In my action class

        public myClass extends ActionSupport implements ModelDriven<BeanClass>
        {
            //My list haveing getters and setters
              public gridModel getGridModel()
               {
                  return gridModel;
                 }
              public void setGridModel(List gridModel)
            { 
                  this.gridModel = gridModel;
             }

           public String methodName()
               {
                  //code here to get the list
                 }
              
            public BeanClass getModel()
                {
                 
                 return new BeanClass();
                 }

          }

What my doubt is I can build the grid when I don't use ModelDriven Interceptor. If I use it then I am unable to bind the list in jqGrid.

I did Google the issue but I can't find the proper solution. As far as I can know the issue is happening when using modelDriven interceptor. This interceptor will keep the action object on top of the ValueStack

Even I tried to use the [1].top but no luck.

EDIT:

I am implementing ModelDriven interface as you said I am missing some specialization I think I have done what you said but still no luck. Don't know where I am missing.

I just did what you said do I need to change anything in my <sjg:grid gridModel = "Here?"> ?

Still can't get the data in jqGrid.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Rookie007
  • 1,229
  • 2
  • 18
  • 50
  • http://stackoverflow.com/q/23976899/573032 – Roman C Jun 09 '14 at 17:25
  • @RomanC I can understand that solution.. `The grid requires some properties to be set to function properly ` What are those properties to be set .. Can you please elaborate more..And I tried `params={ "params.acceptParamNames", "(\\[\\d+\\]\\.)*\\w+((\\.\\w+)|(\\[\\d+\\])|(\\(\\d+\\))|(\\['\\w+'\\])|(\\('\\w+'\\)))*"` this one also.. But cant get the data .. Please help – Rookie007 Jun 10 '14 at 00:38
  • All of them are there, also don't forget to upvote posts that you understood. – Roman C Jun 10 '14 at 08:38
  • @looser http://stackoverflow.com/q/12785891/1654265 – Andrea Ligios Jun 10 '14 at 09:27
  • @RomanC All of them are there . ? May be i am not in satandard to understad. Will you elobrate please .. ? i will give my reputation. – Rookie007 Jun 10 '14 at 10:23

1 Answers1

2

Even I tried to use the [1].top but no luck ..

top references an object on the top of the stack. [1].top references a top object down the stack by index 1. In the first case it's a model pushed on the stack, in the second case it's an action bean pushed on the stack after it's created. I guess the second one contains properties necessary to provide to the grid when the action return json result. These properties are provided in the include parameters of json result. Your action is implemented a ModelDriven interface but with wrong specialization. If your action bean contains the properties that should be serialized to JSON then the model should be the action bean. You can do it if you write your action bean like

public MyClass extends ActionSupport implements ModelDriven
{

  //My list haveing getters and setters
  public String methodName()
  {
    //code here to get the list
  }

  @Override
  public Object getModel() 
  {
    return this;
  }

}   
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • I have done what you suggested but still cant able to get the data.. For more details I have edited my question. Thanks for your time – Rookie007 Jun 11 '14 at 00:26
  • 1
    I didn't find what you have done in the question. In either case will you follow it or not It's a working fine for me. – Roman C Jun 11 '14 at 09:42