服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

jsf的进化――ajax已经来了

   最近在密切关注着java one,ejb3的来临自然是头等大事,但是基于它的应用还不用着急。今天看到了关于jsf的报道,倒是值得拿来说说。
来看看jsf最新基于ajax的api,已经把ajax简单地封装到底了:
1.自动填表栏
jsf的进化――ajax已经来了(图一)


代码:       
<ui:autocomplete size="40" maxlength="100" id="cityfield" completionmethod="#applicationbean.completecity}"    value="#{sessionbean.city}" required="true" ondisplay="function(item) { return extractcity(item); }"    onchoose="function(item) { return choosecity(item); }"/>

2. google map


jsf的进化――ajax已经来了(图二)

点击查看大图

代码:
 <ui:mapviewer id="mapviewerx" center="#{mapbean.mappoint}" info="#mapbean.mapmarker}"
     markers="#{mapbean.locations}" style="height: 500px; width: 700px"/>


3. 选值填入的输入框
jsf的进化――ajax已经来了(图三)

4. 文档编辑器

jsf的进化――ajax已经来了(图四)

5. 类yahoo的打分按钮
jsf的进化――ajax已经来了(图五)
代码:
<ui:rating id="rating" maxgrade="5" includenotinterested="true" includeclear="true"
   hovertexts="#{ratingbean.ratingtext}" notinterestedhovertext="not interested"
   clearhovertext="clear rating" grade="#{ratingbean.grade}"/>

6. 日历
jsf的进化――ajax已经来了(图六)
jsf的进化――ajax已经来了(图七)

7. 表单验证
jsf的进化――ajax已经来了(图八)

点击查看大图

代码:
<ui:ajaxvalidator messageid="input1" eventhook="onkeypress">
          <h:inputtext>
            <f:validatelength minimum="3" />
          </h:inputtext>
</ui:ajaxvalidator>

8. 上传工具
jsf的进化――ajax已经来了(图九)
代码:
<ui:fileuploadtag id="testfileuploadform0" enctype="multipart/form-data"
      retfunction="testretfunction" retmimetype="text/xml" postprocessingmethod="#{fileuploadprocessing.postprocessingmethod}"
        progressbardivid="progress" progressbarsubmitid="submit1x" progressbarsize="40">
            <input type="file" size="40" name="filetoupload0" id="filetoupload0id"/><br>
            <input type="file" size="40" name="filetoupload1" id="filetoupload1id"/><br>
            <input type="file" size="40" name="filetoupload2" id="filetoupload2id"/><br>
            <input type="submit" name="submit1x" value="submit"/>
      <div id="progress"></div><br/>
</ui:fileuploadtag>

现在这个ajax的组件还处在blueprint中,无法直接下载使用,可以通过sun的java creator安装试用,本人觉得jsf的思想是从.net那边抄过来的,所以没有个好使的ide支持写起程序来是挺费劲的。
有兴趣的朋友可以通过这个网址了解更多:http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/ajax_samples.html

扫描关注微信公众号