0

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.

Luke Woodward
  • 63,336
  • 16
  • 89
  • 104
  • Your strutsconfig isn't valid XML. There's a `` closing tag that shouldn't be there. – Luke Woodward Jul 07 '12 at 10:53
  • And check whether you placed `<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>` in your jsp or not and you should add `displaytag-export-poi-1.2` `displaytag-portlet-1.2` jar files to lib directory – Clarence Jul 07 '12 at 10:59
  • @Clarence i added taglib and all required jar files sorry for not stating it and my home page has link to `data retrieval` and my struts config file has `` when i click it url displayed is [link]http://localhost:8080/Dailysheet/DailysheetList.do but does not do any action .and i want is when my required data is in arraylist dailysheetdata in Action Class and i want to display them in jsp with pagination – Kranthi Kumar Jul 07 '12 at 14:09
  • i edited my answer check – Clarence Jul 07 '12 at 18:56

1 Answers1

1

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);
Clarence
  • 896
  • 1
  • 9
  • 27
  • i implemented them from same tutorial but mine is not working and i stated error in above comment it is not going into action class when clicked link dataretrieval which is defined above may be wrong in my strutsconfig .xml – Kranthi Kumar Jul 07 '12 at 14:14
  • i used removed the form and used attribute and solved ,i edited the struts config file as above – Kranthi Kumar Jul 12 '12 at 05:56