AjaxTags標(biāo)記初探
文章是在這里了,但我也沒(méi)把這些文件弄到手。唉,不知如何是好。
AjaxTags項(xiàng)目是在現(xiàn)有的Struts HTML標(biāo)記庫(kù)的基礎(chǔ)上,添加對(duì)AJAX支持
?
AjaxTags項(xiàng)目是在現(xiàn)有的Struts HTML標(biāo)記庫(kù)的基礎(chǔ)上,添加對(duì)AJAX支持。 AjaxTags改寫(xiě)了Struts標(biāo)簽類(lèi)org.apache.struts.taglib.html.FormTag和org.apache.struts.taglib.html.BaseHandlerTag,并使用Struts的plugin技術(shù),使得Struts提供了對(duì)AJAX的支持。 以下是jsp中簡(jiǎn)單的示例:
<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屬性中內(nèi)容是在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> |
在配置文件中定義了該表單的屬性,以及按鈕觸發(fā)的事件和回寫(xiě)結(jié)果的處理方法。采用很巧妙的封裝方法實(shí)現(xiàn)了Struts的AJAX調(diào)用。當(dāng)然Ajaxtags離實(shí)用階段還有相對(duì)長(zhǎng)的一段距離,但它提供了一種在現(xiàn)有的軟件架構(gòu)上高效率開(kāi)發(fā)ajax應(yīng)用程序的可行性方案。
posted on 2006-11-26 17:22
一手的小窩窩 閱讀(167)
評(píng)論(0) 編輯 收藏 所屬分類(lèi):
JAVA