Appfuse: Adding custom page Components

Source: Internet
Author: User

I used to do ASP, and when I came across a similar component that was used by multiple pages, I wanted to use the ascx (user-defined component) to solve it, and that's what I wanted to do with Java.

The effect I have to do is as follows:

Implementation scenario: Tag mode (custom label)

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" >Ten<div id= "Divrecomment" > One<fmt:message key= "Recomment.title"/> A&nbsp;&nbsp; -<select id= "recommendaction" name= "Recommendaction" > -<c:foreach items= "${recommenttype}" var= "T" > the<option value= "${t.key}" >${t.value}</option> -</c:forEach> -<select> -&nbsp;&nbsp; <input type= "button" onclick= "handlerecomment ();" +Value= ' <fmt:message key= "recomment.submit"/> 'class= "Btn btn-primary"/> -</div> +</form>
Recommend.tag

2. Using a custom Label

<%@ taglib prefix= "T" tagdir= "/web-inf/tags"%>

<t:recommend table= "" idfield= "" ></t:recommend>

3. Recommenttype Data Source: Use the HandleRequest in the controller that corresponds to the page

1 New Hashmap<string,string>(); 2         Recommenttype.put ("1", "Home");   3         Recommenttype.put ("2", "other");    4         Request.setattribute (Constants.recomment_type, Recommenttype);
HandleRequest

Styles attached to

1 #divRecomment {2    margin-left:12px;  3 }4#divRecomment Select{5    width:200px;  6    height:38px;  7    border:1px solid #cccccc;  8 }
Main.css

Appfuse: Adding custom page Components

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.