1

This is the point: I want to create a layout for all my datagrids of my web applications using this template (example), if not what do you recomend to do this?: (IS NECESSARY TO BE DYNAMIC)

Layout.java

class Layout {
   public abstract String buttons();
   public abstract String data();
   public String print()
   {
       String layoutOutput = "<div class=\"buttons\">";
       layoutOutput = layoutOutput + this.buttons();
       layoutOutput = layoutOutput + "</div>";
       layoutOutput = "<div class=\"data\">";
       layoutOutput = layoutOutput + this.data();
       layoutOutput = layoutOutput + "</div>";   
       return layoutOutput;
   }
}

MyList.java

class MyList extends Layout {
   public String buttons()
   {
      return "<button>One</button><button>Two</button>";
   }

   public String data()
   {
      return "<table>...</table>";
   }
}

MyJSP.jsp

<%

MyList l = new MyList();
response.write( l.print() );

%>
  • No, it's not a good design. See [why scriptlets are discouraged](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files?rq=1). Implementing a [custom JSP tag](http://www.tutorialspoint.com/jsp/jsp_custom_tags.htm) should improve the design as it's a standard solution for this kind of problems. – SME_Dev Mar 07 '16 at 09:50

0 Answers0