学习网考试学习资料

Gzu521.com

Ajax Tags标记初探

Javascript教程   点击:次   发布时间:2006-7-13   【字体: 】   来源:Gzu521.com
Gzu521.com我的学习网
  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应用程序的可行性方案。

责任编辑:gzu521

网页设计分类
HTML教程
CSS教程
Javascript教程
Dreamweaver教程
FrontPages教程
FireWorks教程
Flash教程
PhotoShop教程
建站知识
分类推荐信息
更多...
大类最新文章
更多...