动态构建类似于 STRUTS 和 Jakarata Tag Lib 的 html 输入文本框
可以使用自定义标签来清理此表单输入元素吗?
<input name="action_for" type="text" value="<c:if test="${empty commitmentItem.action_for}">
<c:out value="${param.action_for}" escapeXml='false' /></c:if>
<c:if test="${not empty commitmentItem.action_for}">
<c:out value="${commitmentItem.action_for}" /></c:if>"
size="16" maxlength="16" />
我只想输入:
<myTag:input field="action_for" obj="commitmentItem" />
或类似的内容。
我只是不知道如何访问请求以及 value 属性的标记处理程序类中的 bean 数据
我可以弄清楚如何创建一个简单的标记来生成指向 javascript 的链接弹出窗口小部件。
<myTag:calPOP field="ecd_date" />
它生成此链接:
<A HREF="javascript:cal1xx.select(document.forms[0].ecd_date,'ecd_date_anchor','MM/dd/yyyy');"
TITLE="Click to Select a Date" NAME="ecd_date_anchor" ID="ecd_date_anchor"> CALENDAR</A>
...这里是一些标记处理程序...
public int doStartTag() throws JspException {
try {
JspWriter out = pc.getOut();
out.println(" <a href=\"javascript:cal1xx.select(document.forms[0]."
+ field
+ ",'"
+ field
+ "_anchor','MM/dd/yyyy');\" TITLE=\"Click to Select a Date\" NAME=\""
+ field
+ "_anchor\" ID=\""
+ field
+ "_anchor\">CALENDAR</a>");
}
catch (IOException e) {
throw new JspTagException("An IOException occurred.");
}
return EVAL_BODY_AGAIN;
}
我没有使用 STRUTS 并且不能使用 EL
Can a custom tag be utilized to clean up this form input element?
<input name="action_for" type="text" value="<c:if test="${empty commitmentItem.action_for}">
<c:out value="${param.action_for}" escapeXml='false' /></c:if>
<c:if test="${not empty commitmentItem.action_for}">
<c:out value="${commitmentItem.action_for}" /></c:if>"
size="16" maxlength="16" />
I'd like to just type:
<myTag:input field="action_for" obj="commitmentItem" />
or something similar.
I just don't know how to access the request and also the bean data from within the tag handler class for the value attribute
I could figure out how to do a simple tag for generating a link to the javascript POP-Up widget.
<myTag:calPOP field="ecd_date" />
which generates this link:
<A HREF="javascript:cal1xx.select(document.forms[0].ecd_date,'ecd_date_anchor','MM/dd/yyyy');"
TITLE="Click to Select a Date" NAME="ecd_date_anchor" ID="ecd_date_anchor"> CALENDAR</A>
... here is a bit of the tag handler for that...
public int doStartTag() throws JspException {
try {
JspWriter out = pc.getOut();
out.println(" <a href=\"javascript:cal1xx.select(document.forms[0]."
+ field
+ ",'"
+ field
+ "_anchor','MM/dd/yyyy');\" TITLE=\"Click to Select a Date\" NAME=\""
+ field
+ "_anchor\" ID=\""
+ field
+ "_anchor\">CALENDAR</a>");
}
catch (IOException e) {
throw new JspTagException("An IOException occurred.");
}
return EVAL_BODY_AGAIN;
}
I am not using STRUTS and can not utilize EL
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论