Java javax.servlet.jsp.tagext.Tag 代码实例

作者:无名 - 开发 -

以下是展示如何使用javax.servlet.jsp.tagext.tag的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了最佳的优秀示例。

实例 1


@test

public void testtagbasics() throws jspexception {

for (wro4jtag tag : aslist(alltag(), csstag(), jstag())) {

tag.setname("mixed-resources-1");

assertequals(tag.skip_body, tag.dostarttag());

assertequals(tag.eval_page, tag.doendtag());

}

}

实例 2


@override

public int doendtag() throws jspexception {

pagecontext

.removeattribute(variable_scope_name, pagecontext.page_scope);

pagecontext.removeattribute(asset_dao, pagecontext.page_scope);

return tag.eval_page;

}

实例 3


@override

public int doendtag() throws jspexception {

//from portlet:defineobjects

final renderrequest renderrequest = (renderrequest)this.pagecontext.getattribute("renderrequest");

final renderresponse renderresponse = (renderresponse)this.pagecontext.getattribute("renderresponse");

final portletdelegationlocator portletdelegationlocator = (portletdelegationlocator)renderrequest.getattribute(portletdelegationlocator.portlet_delecation_locator_attr);

final string sessionkey = this.sessionkeyprefix + this.fname;

final portletsession portletsession = renderrequest.getportletsession();

iportletwindowid portletwindowid = (iportletwindowid)portletsession.getattribute(sessionkey);

final portletdelegationdispatcher portletdelegationdispatcher;

final delegatestate delegatestate;

//no id in session, create a new dispatcher

if (portletwindowid == null) {

portletdelegationdispatcher = portletdelegationlocator.createrequestdispatcher(renderrequest, this.fname);

portletwindowid = portletdelegationdispatcher.getportletwindowid();

portletsession.setattribute(sessionkey, portletwindowid);

final portletmode portletmode = portletutils.getportletmode(this.portletmode);

final windowstate windowstate = portletutils.getwindowstate(this.windowstate);

delegatestate = new delegatestate(portletmode, windowstate);

}

//id in session, get the old dispatcher

else {

portletdelegationdispatcher = portletdelegationlocator.getrequestdispatcher(renderrequest, portletwindowid);

delegatestate = null;

}

final delegationrequest delegationrequest = new delegationrequest();

delegationrequest.setdelegatestate(delegatestate);

//setup base for portlet urls

delegationrequest.setparentportletmode(this.parenturlmode);

delegationrequest.setparentwindowstate(this.parenturlstate);

delegationrequest.setparentparameters(this.parenturlparameters);

final jspwriter out = this.pagecontext.getout();

try {

portletdelegationdispatcher.dorender(renderrequest, renderresponse, delegationrequest, new jspwriterportletoutputhandler(out, renderresponse));

}

catch (ioexception e) {

throw new jspexception("failed to execute delegate render on portlet '" + this.fname + "'", e);

}

return tag.eval_page;

}

实例 4


@override

public int dostarttag() throws jspexception {

try {

string resulturl = "";

string[] codes = code.split(",");

functionmanager functionmanager=(functionmanager)contextutils.getbean("functionmanager");

if(stringutils.isempty(systemcode)){

systemcode = contextutils.getsystemcode();

}

for(string mycode:codes){

if(contextutils.isauthority(mycode)){

string path = functionmanager.getfunctionpathbycode(mycode, systemcode);

resulturl = systemurls.getsystemurl(systemcode)+ path;

break;

}

}

//jsp

pagecontext.getout().print(resulturl);

} catch (exception e) {

throw new jspexception(e);

}

return tag.eval_page;

//

//return skip_body;

}

实例 5


@override

public int dostarttag() throws jspexception {

log.debug("***dostarttag***");

log.debug(new stringbuilder("*** veriable:[")

.append("taskid:").append(taskid)

.append("]").tostring());

webroot = servletactioncontext.getrequest().getcontextpath();

jspwriter out=pagecontext.getout();

listlt;workflowattachmentgt; attachments = null;

if(taskid != null amp;amp; taskid!=0) {

workflowinstancemanager workflowinstancemanager = (workflowinstancemanager) contextutils.getbean("workflowinstancemanager");

com.norteksoft.product.api.entity.workflowtask task = apifactory.gettaskservice().gettask(taskid);

string workflowid = task.getprocessinstanceid();

attachments = workflowinstancemanager.getattachments(workflowid,getcompanyid());

if(taskstate.completed.getindex().equals(task.getactive())||taskstate.cancelled.getindex().equals(task.getactive())){

deleteright=false;

addright=false;

downloadright=false;

}else{

taskpermissionpermission = apifactory.getpermissionservice().getactivitypermission(taskid);

deleteright=permission.getattachmentdeletable();

addright=permission.getattachmentcreateable();

downloadright=permission.getattachmentdownloadable();

}

}

try {

out.print(readtemplet(attachments));

} catch (exception e) {

log.error(e);

throw new jspexception(e);

}

log.debug("***dostarttag***");

return tag.eval_page;

}

实例 6


/**

* lt;pgt;returns the bean name from the request object that the properties

* are nesting against.lt;/pgt;

*

* lt;pgt;the requirement of the tag itself could be removed in the future,

* but is required if support for the lt;html:formgt; tag is maintained.lt;/pgt;

*

* @param request object to fetch the bean reference from

* @param nestedtag from which to start the search from

* @return the string of the bean name to be nesting against

*/

public static final string getcurrentname(httpservletrequest request,

nestednamesupport nested) {

// get the old one if any

nestedreference nr =

(nestedreference) request.getattribute(nested_includes_key);

// return null or the property

if (nr != null) {

return nr.getbeanname();

} else {

// need to look for a form tag...

tag tag = (tag) nested;

tag formtag = null;

// loop all parent tags until we get one that can be nested against

do {

tag = tag.getparent();

if ((tag != null) amp;amp; tag instanceof formtag) {

formtag = tag;

}

} while ((formtag == null) amp;amp; (tag != null));

if (formtag == null) {

return "";

}

// return the form's name

return ((formtag) formtag).getbeanname();

}

}

实例 7


/**

* process the tag.

*/

public int dostarttag()

throws jspexception

{

if (_name == null)

return skip_body;

if (_value == null)

return eval_body_buffered;

tag parent = getparent();

for (; parent != null; parent = parent.getparent()) {

if (parent instanceof namevaluetag) {

namevaluetag tag = (namevaluetag) parent;

if (_value == null)

tag.addparam(_name, "");

else

tag.addparam(_name, _value);

return skip_body;

}

}

throw new jspexception(l.l("c:param requires c:url or c:import parent."));

}

实例 8


/**

* process the tag.

*/

public int dostarttag()

throws jspexception

{

object value = _value;

long time = 0;

object result = null;

if (value == null) {

}

else if (value instanceof number)

time = ((number) value).longvalue();

else if (value instanceof java.util.date)

time = ((java.util.date) value).gettime();

else if (value instanceof java.sql.date)

time = ((java.sql.date) value).gettime();

else

throw new jspexception(l.l("sql:dateparam requires at date at '{0}'", value));

if (value == null)

result = null;

else if (_type == null)

result = new java.sql.timestamp(time);

else if (_type.equals("time"))

result = new java.sql.time(time);

else if (_type.equals("date"))

result = new java.sql.date(time);

else if (_type.equals("timestamp"))

result = new java.sql.timestamp(time);

else

throw new jspexception(l.l("sql:dateparam type='{0}' is an unknown type",

_type));

tag parent = getparent();

for (;

parent != null amp;amp; ! (parent instanceof sqlexecutiontag);

parent = parent.getparent()) {

}

if (parent == null)

throw new jspexception(l.l("sql:dateparam requires sql:query parent."));

sqlexecutiontag tag = (sqlexecutiontag) parent;

tag.addsqlparameter(result);

return skip_body;

}

实例 9


/**

* lt;pgt;returns the bean name from the request object that the properties

* are nesting against.lt;/pgt;

*

* lt;pgt;the requirement of the tag itself could be removed in the future,

* but is required if support for the lt;html:formgt; tag is maintained.lt;/pgt;

*

* @param request object to fetch the bean reference from

* @param nestedtag from which to start the search from

* @return the string of the bean name to be nesting against

*/

public static final string getcurrentname(httpservletrequest request,

nestednamesupport nested) {

// get the old one if any

nestedreference nr =

(nestedreference) request.getattribute(nested_includes_key);

// return null or the property

if (nr != null) {

return nr.getbeanname();

} else {

// need to look for a form tag...

tag tag = (tag) nested;

tag formtag = null;

// loop all parent tags until we get one that can be nested against

do {

tag = tag.getparent();

if ((tag != null) amp;amp; tag instanceof formtag) {

formtag = tag;

}

} while ((formtag == null) amp;amp; (tag != null));

if (formtag == null) {

return "";

}

// return the form's name

return ((formtag) formtag).getbeanname();

}

}

实例 10


public static final cewolfroottag findroot(tag t, pagecontext ctx){

tag res = t;

while(!(res instanceof cewolfroottag)){

res = res.getparent();

}

return (cewolfroottag)res;

}

实例 11


public synchronized static cftag getparentcftag(tag tag,string trgtagname, int minlevel) {

string purename=trgtagname;

int level=0;

cftag cftag;

while(tag!=null) {

if(tag instanceof cftag amp;amp; minlevellt;=(level++)) {

cftag=(cftag)tag;

if(cftag instanceof cftagcore){

cftagcore tc=(cftagcore) cftag;

if((tc.getname()+"").equalsignorecase(purename))

return cftag;

if(stringutil.startswithignorecase(purename,"cf")) {

purename=purename.substring(2);

}

if((tc.getname()+"").equalsignorecase(purename))

return cftag;

}

else if( cftag.getappendix().equalsignorecase(purename)) {

return cftag;

}

else if(stringutil.startswithignorecase(purename,"cf_")) {

purename=purename.substring(3);

if(cftag.getappendix().equalsignorecase(purename))

return cftag;

}

}

tag=tag.getparent();

}

return null;

}

实例 12


public static string call(pagecontext pc, string delimiter) {

tag tag=pc.getcurrenttag();

stringbuffer sb=new stringbuffer();

while(tag!=null) {

if(sb.length()gt;0)sb.append(delimiter);

sb.append(getname(pc,tag));

tag=tag.getparent();

}

return sb.tostring();

}

实例 13


/**

* evaluates if body content within lt;authorizegt; tag is to be included.

*/

@override

public int dostarttaginternal() throws jsptagexception {

action action = null;

final set userroles = this.getprincipalroles();

// no params specified

if ((null == this.actionid || 0 gt;= this.actionid) amp;amp; (null == this.actionname || "".equals(this.actionname)) amp;amp; null == this.ruleobject) {

return tag.skip_body;

}

// get logged in user

if (this.ruleobject != null) {

/*

* authentication currentuser = securitycontextholder.getcontext() .getauthentication(); if (ruleobject.isauthorized(currentuser)) return eval_body_include; else return skip_body;

*/

}

//

final actionservice rbacservice = (actionservice) getrequestcontext().getwebapplicationcontext().getbean("actionservice");

if (this.actionname != null) {

action = rbacservice.getactionbyname(this.actionname);

}

if (this.actionid != null) {

action = (action)rbacservice.getactionbyid(this.actionid);

}

if (action != null) {

// if user's role belongs to action roles

final set actionroles = action.getroles();

final set grantedcopy = this.retainall(userroles, actionroles);

if (grantedcopy.isempty()) {

return tag.skip_body;

}

}

return tag.eval_body_include;

}

实例 14


public int dostarttag()

throws jspexception

{

uicomponentclassictagbase parent

= uicomponentclassictagbase.getparentuicomponentclassictagbase(pagecontext);

if (parent == null)

throw new jspexception(

"convertereltag must be nested inside a uicomponent tag.");

if (parent.getcreated()) {

uicomponent component = parent.getcomponentinstance();

if (!(component instanceof valueholder))

throw new jspexception(

"uicomponent parent of converter must be a valueholder.");

converter converter = createconverter();

valueholder valueholder = (valueholder) component;

valueholder.setconverter(converter);

object obj = valueholder.getlocalvalue();

if (obj instanceof string) {

facescontext context = facescontext.getcurrentinstance();

object value = converter.getasobject(context,

component,

(string) obj);

valueholder.setvalue(value);

}

}

return tag.skip_body;

}

实例 15


/**

* puts the body content inside an attribute lt;codegt;jscontainerlt;/codegt;.

* @throws javax.servlet.jsp.jspexception

*/

public int doafterbody() throws jspexception {

scriptcontainer container = scriptcontainer.get(pagecontext);

container.push(getbodycontent());

return tag.skip_body;

}



IT人知识库 原文地址:http://www.itpeo.net/389615/4638958.html





标签 代码实例

Java javafx.beans.property.StringProperty 代码实例

以下是展示如何使用javafx.beans.property.stringproperty的最佳示例。 我们使用了代码质 ...

Java javax.persistence.LockModeType 代码实例

以下是展示如何使用javax.persistence.lockmodetype的最佳示例。 我们使用了代码质量辨别算法从 ...

Java org.eclipse.jface.commands.ActionHandler 代码实例

以下是展示如何使用org.eclipse.jface.commands.actionhandler的最佳示例。 我们使用 ...

Python win32con.STILL_ACTIVEs 代码实例

以下是python模块win32con.still_active的代码最佳示例,显示该如何使用sys.stdout。 它 ...

Java org.eclipse.ui.keys.IBindingService 代码实例

以下是展示如何使用org.eclipse.ui.keys.ibindingservice的最佳示例。 我们使用了代码质量 ...

Java org.springframework.http.converter.json.MappingJacksonHttpMessageConverter 代码实例

以下是展示如何使用org.springframework.http.converter.json.mappingjack ...

Python wx.EVT_PAINTs 代码实例

以下是python模块wx.evt_paint的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源pyth ...

Java com.vaadin.data.Property.ValueChangeListener 代码实例

以下是展示如何使用com.vaadin.data.property.valuechangelistener的最佳示例。 ...

Python wx.CENTERs 代码实例

以下是python模块wx.center的代码最佳示例,显示该如何使用sys.stdout。 它们是从开源python项 ...

Java hudson.util.ListBoxModel 代码实例

以下是展示如何使用hudson.util.listboxmodel的最佳示例。 我们使用了代码质量辨别算法从开源项目中提 ...

Java java.sql.RowIdLifetime 代码实例

以下是展示如何使用java.sql.rowidlifetime的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出 ...

Java org.joda.time.Instant 代码实例

以下是展示如何使用org.joda.time.instant的最佳示例。 我们使用了代码质量辨别算法从开源项目中提取出了 ...

Java javax.script.CompiledScript 代码实例

以下是展示如何使用javax.script.compiledscript的最佳示例。 我们使用了代码质量辨别算法从开源项 ...

Java org.apache.commons.httpclient.URI 代码实例

以下是展示如何使用org.apache.commons.httpclient.uri的最佳示例。 我们使用了代码质量辨别 ...

HTML5数据属性的XHTML替代

下载源代码 1.3 kb介绍我倾向于编写自己的跨浏览器 ui组件,并总是努力减少页面中呈现的元素数量,同时确保标记。 在 ...

JsonML简化的Array.prototype.toDomNodes

下载源 2.82 kb介绍本文所提供的代码允许从一个函数调用以标记(。 ) 格式创建dom元素。 这意味着你可以让aja ...

IE的CPHog

下载源文件 7.38 kb介绍[ ^ ]。插入所需内容尽管如此,它在 ie 中不工作。 我想看看是否有一个与 ie 等价 ...

使用JavaScript更改图像的不透明度( 透明)

介绍我认为这种技术特别有用和独特- 使用javascript来改变图像的不透明度 ! 技术既可以用于ie4+和 ns6+ ...

在网页上,将焦点设置为第一个输入

介绍我正在开发一个具有相当复杂的授权逻辑的web应用程序,并将启用和禁用许多不同的web窗体。 例如用户a 将禁用 5个 ...

rfedfre

UIKit框架式单页网页网页

介绍本文将向你展示如何使用 uikit (http://getuikit.com/) 框架制作一个带有侧边面板的高级粘性 ...