AjaxTags標(biāo)記初探
文章是在這里了,但我也沒把這些文件弄到手。唉,不知如何是好。
AjaxTags項目是在現(xiàn)有的Struts HTML標(biāo)記庫的基礎(chǔ)上,添加對AJAX支持
<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ā)的事件和回寫結(jié)果的處理方法。采用很巧妙的封裝方法實現(xiàn)了Struts的AJAX調(diào)用。當(dāng)然Ajaxtags離實用階段還有相對長的一段距離,但它提供了一種在現(xiàn)有的軟件架構(gòu)上高效率開發(fā)ajax應(yīng)用程序的可行性方案。