Search code examples
struts-1displaytag

applying display tag to my project but failed in struts config file


I am applying display tag to my jsp in struts but not able to do it please check out

1.strutsconfig

<form-beans><form-bean name="DailysheetForm" type="com.myapp.struts.DailysheetForm"/>
</formbean>
<action input="/" path="/DailysheetList" name="DailysheetForm"  scope="request"            type="com.myapp.struts.DialysheetListAction">
   <forward name="success" path="/DailysheetList.jsp"/>
</action>

2.Form

public class DailysheetForm extends ActionForm 
 {
// some getter and setter methods i used like receiptno
   protected ArrayList arraylist;
   public ArrayList getArraylist()
     {
       return arraylist;
     }

public void setArraylist(ArrayList arraylist) {

    this.arraylist = arraylist;

}

3.Action Class

public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception {

    ArrayList dailysheetdata;
    DailysheetForm dailyform = (DailysheetForm) form;
    Class.forName("com.mysql.jdbc.Driver");
    Connection connect = DriverManager.getConnection("jdbc:mysql://localhost/Stonecrusher?"
                        + "user=Stonecrusher&password=xxxxxx");
    System.out.println("Connection"+connect);
    dailysheetdata = StoneCrusherData.getDailysheetData(connect);

    dailyform.setArraylist(dailysheetdata) ;
    return mapping.findForward(SUCCESS);
     }

JSP

<display:table id="data"  name="requestScope.DailysheetForm.arraylist"requestURI="/DailysheetList" pagesize="10" >
  <display:column property="receiptno" title="RECEIPTNO" sortable="true"/>
  <display:column property="cutomername" title="CUSTOMER NAME" sortable="true"/>
</display:table>
<display:table id="data" name="requestScope.DailysheetForm.arraylist" requestURI="/DailysheetList" pagesize="10" >
  <display:column property="receiptno" title="RECEIPTNO" sortable="true"/>
  <display:column property="cutomername" title="CUSTOMER NAME" sortable="true"/>
</display:table>

It is not working and basically I am getting data to dailysheetdate which is arraylist in my Action Class and I want to display it in jsp with pagination. I know I was wrong please help me how to do it.


Solution

  • Check your jar files whether you placed all required jars in to lib or not.. still have a problem paste your Error here..

    See the Tutorial for Display Tag

    then you need not Specify input and name attributes in <action> in strutsconfig.xml

    i.e your code should like ethis

    <action path="/DailysheetList" scope="request"  type="com.myapp.struts.DialysheetListAction">
       <forward name="success" path="/DailysheetList.jsp"/>
    </action>
    

    then definitely Action Class will execute..

    And one more thing by seeing your action class code i does't know whether StoneCrusherData object is created or not.. check below line also

    dailysheetdata = StoneCrusherData.getDailysheetData(connect);