Class SelectTag
java.lang.Object
org.javalite.activeweb.freemarker.FreeMarkerTag
org.javalite.activeweb.freemarker.SelectTag
- All Implemented Interfaces:
freemarker.template.TemplateDirectiveModel
,freemarker.template.TemplateModel
,RequestAccess
Select tag is to generate the <select> HTML tag based on data passed in dynamically into a view.
Parameters:
- list - this is a mandatory parameter, and it needs to be type of
java.util.List
filled with instances ofSelectOption
<@select list=books> <option value="3">A Tale of Two Cities</option> </@>And pass this data from controller:
view("books", list(new SelectOption(1, "The Hitchhiker's Guide to the Galaxy"), new SelectOption(2, "All Quiet on Western Front", true)));then the output from the tag will be:
<select> <option value="3">A Tale of Two Cities</option> <option value="1">The Hitchhiker's Guide to the Galaxy</option> <option value="2" selected="true">All Quiet on Western Front</option> </select>Which means that the generated code is appended to hand-written body.
Adding HTML5-style attributes
Use a special attribute "data", whose value will be added to the resulting tag verbatim.<select data="data-greeting='hola' data-bye='astalavista'" > ... </select>
- Author:
- Igor Polevoy: 4/12/12 1:13 PM
-
Field Summary
Fields inherited from interface org.javalite.activeweb.RequestAccess
LOGGER
Fields inherited from interface freemarker.template.TemplateModel
NOTHING
-
Constructor Summary
-
Method Summary
Methods inherited from class org.javalite.activeweb.freemarker.FreeMarkerTag
execute, get, getAllVariables, getContextPath, getUnwrapped, getUnwrapped, logger, overrideContext, process, session, sessionObject, validateParamsPresence
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.javalite.activeweb.RequestAccess
appContext, context, cookie, cookies, cookieValue, exists, format, getId, getLocale, getRequestHost, getRequestPort, getRequestProperties, getRequestProtocol, getRoute, header, headers, host, ipAddress, ipForwardedFor, isDelete, isGet, isHead, isMethod, isMultipartContent, isPost, isPut, isXhr, locale, method, param, param, params, params, params, params1st, params1st, path, port, protocol, queryString, remoteAddress, remoteHost, requestHas, servletPath, session, session, uri, url, userAgent, xhr
-
Constructor Details
-
SelectTag
public SelectTag()
-
-
Method Details
-
render
Description copied from class:FreeMarkerTag
Implement this method ina concrete subclass.- Specified by:
render
in classFreeMarkerTag
- Parameters:
params
- this is a list of parameters as provided to tag in HTML.body
- body of tagwriter
- writer to write output to.- Throws:
Exception
- if any
-