[转载]AjaxTags标记初探

AjaxTags标记初探
AjaxTags项目是在现有的Struts HTML标记库的基础上,添加对AJAX支持。 AjaxTags改写了Struts标签类org.apache.struts.taglib.html.FormTag和org.apache.struts.taglib.html.BaseHandlerTag,并使用Struts的plugin技术,使得Struts提供了对AJAX的支持。 以下是jsp中简单的示例:

<html:form action="example1" ajaxRef="example1">
  First Name: <html:text property="firstName" size="25" value="Frank" />
  <br>
  Last Name: <html:text property="lastName" size="25" value="Zammetti" />
  <br>
  <html:button property="button" value="Click to do Ajax!" ajaxRef="button" />
</html:form>
Result:<br>
<span id="example1_resultLayer"> </span>

  注意:ajaxRef属性。 ajaxRef属性中内容是在ajax-config.xml中定义的,例如本示例的配置部分如下:

<!DOCTYPE ajaxConfig PUBLIC "ajaxConfig" "ajaxConfig">
<ajaxConfig>
  <!-- Define a custom request handler that generates XML for example 2 -->
   <handler name="CustomXMLGenerator" type="request">
      <function>customGenerateXML</function>
      <location>customXMLGenerator.js</location>
   </handler>
   <!-- Configuration for example 1 -->
   <form ajaxRef="example1">
      <element ajaxRef="button">
         <event type="onclick">
            <requestHandler type="std:QueryString">
               <target>example1.do</target>
               <parameter>firstName=firstName,lastName=lastName</parameter>
            </requestHandler>
            <responseHandler type="std:InnerHTML">
               <parameter>example1_resultLayer</parameter>
            </responseHandler>
         </event>
      </element>
   </form>
</ajaxConfig>

  在配置文件中定义了该表单的属性,以及按钮触发的事件和回写结果的处理方法。采用很巧妙的封装方法实现了Struts的AJAX调用。当然Ajaxtags离实用阶段还有相对长的一段距离,但它提供了一种在现有的软件架构上高效率开发ajax应用程序的可行性方案。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/374079/viewspace-131149/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/374079/viewspace-131149/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值