macros.vm 8.75 KB
#** -------------------------------------------
 * 显示所有headers
 * -------------------------------------------- *#
#macro (showHead $defaultTitle)
    #showTitle ($defaultTitle)
    #showMetaTags ()
    #showHttpEquiv ()
    #showStylesheets ()
    #showJavascripts ()
#end

#** -------------------------------------------
 * 显示标题,如果未提供标题,则使用默认值
 * -------------------------------------------- *#
#macro (showTitle $defaultTitle)
    #if( $page.title != "" )
		<title>$page.message("web_site_name") - $page.title</title>
    #else
		<title>$!defaultTitle</title>
    #end
#end

#** -------------------------------------------
 * 显示meta tags
 * -------------------------------------------- *#
#macro (showMetaTags)
    #foreach($metaTag in $page.metaTags.keySet())
    <meta name="$metaTag" content="$page.metaTags.get($metaTag)">
    #end
#end

#** -------------------------------------------
 * 显示meta http-equiv
 * -------------------------------------------- *#
#macro (showHttpEquiv)
    #foreach($httpEquiv in $page.httpEquivs.keySet())
    <meta http-equiv="$httpEquiv" content="$page.httpEquivs.get($httpEquiv)">
    #end
#end

#** -------------------------------------------
 * 显示stylesheets
 * -------------------------------------------- *#
#macro (showStylesheets)
    #foreach( $styleSheet in $page.styleSheets )
    <link rel="stylesheet" href="$styleSheet.Url"
      #if($styleSheet.Type != "" ) type="$styleSheet.Type" #end
      #if($styleSheet.Media != "") media="$styleSheet.Media" #end
      #if($styleSheet.Title != "") title="$styleSheet.Title" #end>
    #end
#end

#** -------------------------------------------
 * 显示javascripts
 * -------------------------------------------- *#
#macro (showJavascripts)
    #foreach( $script in $page.scripts )
    <script type="text/javascript" src="$script" language="JavaScript"></script>
    #end
#end


#** -------------------------------------------
 * 显示body attributes
 * -------------------------------------------- *#
#macro (bodyAttributes)
    #foreach( $attributeName in $page.bodyAttributes.keySet() )
        $attributeName="$page.bodyAttributes.get($attributeName)"
    #end
#end


#** -------------------------------------------
 * 显示radio
 * -------------------------------------------- *#
#macro (radio $name $property $value)
 <input type="radio" name=$name value="$value" #if ($property==$value) checked #end/>
#end

#** -------------------------------------------
 * 文本信息显示
 * @param $text 要显示的内容
 * @param $msgStyle 指定css样式
 * -------------------------------------------- *#
#macro (showMessage $text $msgStyle)
    #if($text)<div class=$msgStyle>$!text</div>#end
#end

#** -------------------------------------------
 * 表单验证信息显示
 * @param $text 要显示的内容
 * @param $msgStyle 指定css样式
 * -------------------------------------------- *#
#macro (formValidation $msg $default)
	#if($msg)
		<span class="errorMessage">$!msg</span>
	#elseif($default)
		<span class="small">$!default</span>
	#end
#end

#** -------------------------------------------
 * 表单验证信息必填项标识
 * -------------------------------------------- *#
#macro (requiredFiled)
	<span style="color:red;">(*)</span>
#end

#** -------------------------------------------
 * td内容部分显示,当鼠标移到上面显示全部
 * @param $field 要显示的内容
 * @param $width 显示的宽度
 * -------------------------------------------- *#
#macro (ellipsis $field $width)
	<span>$stringUtil.substring($field, 0 ,$width)#if($field.length() > $width)...#end</span>
#end

#** -------------------------------------------
 * 显示select box
 * @param $name select name
 * @param $map select option map
 * @param $selected selected value
 * @param $hint int value
 * @param $attributes
 * -------------------------------------------- *#
#macro (select $name $map $selected $hint $attributes)
    #set ($_map = $map)
    #set ($_selected = $selected)
    #set ($_attributes = $stringUtil.split($attributes,";"))
    <select name="$name" #foreach($_attr in $_attributes) $_attr#end>
    #if ($hint != "")
      <option value="">$hint</option>
    #end
    
    #foreach ($_key in $_map.keySet())
      <option value="$_key" #if ($_key == $_selected) selected #end>$_map.get($_key)</option>
    #end
    </select>
#end

#** -------------------------------------------
 * 显示级联select box,目前支持两级
 * @param $name select name
 * @param $map select option map
 * @param $selected selected value
 * @param $hint int value
 * @param $attributes
 * -------------------------------------------- *#
#macro (cascadeSelect $name $name2 $json $selected $hint $attributes)
    #set ($_id = $stringUtil.replace($name, '.', '_'))
	#set ($_id2 = $stringUtil.replace($name2, '.', '_'))
    #set ($_selected = $selected)
    #set ($_attributes = $stringUtil.split($attributes,";"))
    <select id="$_id" name="$name" #foreach($_attr in $_attributes) $_attr#end>
    </select>
    <script type="text/javascript">
    jQuery(document).ready(function(){
    	jQuery('#$_id').selectLink('#$_id2', eval('$json'), '$!selected', '$!hint');
    });
    </script>
#end


#** -------------------------------------------
 * 显示check box
 * @param $name checkbox name
 * @param $map checkbox
 * @param $checkedList
 * @param $class
 * -------------------------------------------- *#
#macro (checkbox $name $map $checkedList $class)
    #set ($_map = $map)
    #set ($_checked = $checkedList)
	
	#foreach ($_key in $_map.keySet())
	#set ($_value = $_key + "----" + $_map.get($_key))
	<span #if($class)class="$!class"#end>
		<input type="checkbox" name="$!name" value="$_value" #foreach($_tmp in $_checked)#if($_key == $_tmp) checked #end#end/>
		<label>$_map.get($_key)</label>
	</span>
	#end
#end

#** -------------------------------------------
 * 显示分页信息
 * -------------------------------------------- *#
#macro (pagination)
	<div class="pagination"></div>
	<input type="hidden" value="$total" name="num_entries" id="num_entries" class="numeric"/>
	<input type="hidden" value="#if(!$currentPage)0#else$currentPage#end" name="current_page" id="current_page" class="numeric"/>
	<input type="hidden" value="$request.getRequestURI()?$request.getQueryString()" name="link_to" id="link_to"  class="numeric"/>
	<input type="hidden" value="3" name="items_per_page" id="items_per_page" class="numeric"/>
	<input type="hidden" value="10" name="num_display_entries" id="num_display_entries" class="numeric"/>
	<input type="hidden" value="2" name="num_edge_entries" id="num_edge_entries" class="numeric"/>
	<input type="hidden" value="上一页" name="prev_text" id="prev_text" class="numeric"/>
	<input type="hidden" value="下一页" name="next_text" id="next_text" class="numeric"/>
#end


#** -------------------------------------------
 * 多文件上传
 * @param $action 指定请求提交的后台程序(必须通过该参数接收文件数据:MultipartFile fileData)
 * @param $param 以post方式传递的参数,必须是json格式的
 * @param $fileExt 上传文件的扩展名,启用本项时需同时声明fileDesc
 * @param $fileDesc 出现在上传对话框中的文件类型描述
 * @param $sizeLimit 控制上传文件的大小,单位byte
 * -------------------------------------------- *#
#macro (multiFileUpload $action $param $fileExt $fileDesc $sizeLimit)
    <link href="$uribroker.styles.setTarget("uploadify.css")" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="$page.url("/scripts/swfobject.js")"></script>
    <script type="text/javascript" src="$page.url("/scripts/jquery.uploadify.v2.1.0.min.js")"></script>
    <script type="text/javascript" src="$page.url("/scripts/zeus-multifileupload.js")"></script>
    
	<input type="hidden" name="uploader" value='$uribroker.flash.setTarget("uploadify.swf")' class="uploadify"/>
	<input type="hidden" name="cancelImg" value='$uribroker.images.setTarget("cancel.png")' class="uploadify"/>
    <input type="hidden" name="script" value='$action' class="uploadify"/>
    <input type="hidden" name="scriptData" value="$param" class="uploadify"/>
    <input type="hidden" name="fileExt" value="$fileExt" class="uploadify"/>
    <input type="hidden" name="fileDesc" value="$fileDesc" class="uploadify"/>
    <input type="hidden" name="sizeLimit" value="$sizeLimit" class="uploadify"/>
    <input type="hidden" id="successMsg" value='$page.message("100001")'/>
    <input type="hidden" id="failureMsg" value='$page.message("100002")'/>
    <div id="fileQueue"></div>
    <input type="file" name="uploadify" id="uploadify"/>
    <p><a href="javascript:jQuery('#uploadify').uploadifyUpload()">上传文件</a> | <a href="javascript:jQuery('#uploadify').uploadifyClearQueue()">取消上传队列</a> | <a href='$uribroker.shopDetail?sId=$request.getParameter("sId")'>确定</a></p>
#end