Appfuse: add custom page components and appfuse custom
I used to do ASP. NET, after encountering similar components used by multiple pages, I want to use ascx (user-defined components) to solve the problem. I also want to use this solution for Java.
I want to do the following:
Implementation Scheme: tag mode (custom tag)
1. First define your own tag
1 <% @ tag body-content = "scriptless" pageEncoding = "UTF-8" %> 2 <% @ attribute name = "table" required = "true" %> 3 <% @ attribute name = "idfield" required = "true" %> 4 <% @ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %> 5 <% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> 6 <c: set var = "base" value = "$ {pageContext. request. contextPath} "/> 7 <c: set var =" typeList "/> 8 <script src =" <c: url value = "/scripts/jquery/jquery.1.10.2.min. js "/>"> </script> 9 <form method = "post"> 10 <div id = "divRecomment"> 11 <fmt: message key = "recomment. title "/> 12 & nbsp; 13 <select id =" recommendAction "name =" recommendAction "> 14 <c: forEach items = "$ {recommenttype}" var = "t"> 15 <option value = "$ {t. key} ">$ {t. value} </option> 16 </c: forEach> 17 <select> 18 & nbsp; <input type = "button" onclick = "handleRecomment (); "19 value = '<fmt: message key =" recomment. submit "/> 'class =" btn-primary "/> 20 </div> 21 </form>Recommend. tag
2. Use custom tags
<% @ Taglib prefix = "t" tagdir = "/WEB-INF/tags" %>
<T: recommend table = "" idfield = ""> </t: recommend>
3. recommenttype Data source: Use handleRequest in the Controller corresponding to the page
1 HashMap <String, String> recommentType = new HashMap <String, String> (); 2 recommentType. put ("1", "Homepage"); 3 recommentType. put ("2", "other"); 4 request. setAttribute (Constants. RECOMMENT_TYPE, recommentType );HandleRequest
Styles used
1 # divRecomment {2 margin-left: 12px; 3} 4 # divRecomment select {5 width: 200px; 6 height: 38px; 7 border: 1px solid # cccccc; 8}Main.css