最近在密切关注着java one,ejb3的来临自然是头等大事,但是基于它的应用还不用着急。今天看到了关于jsf的报道,倒是值得拿来说说。
来看看jsf最新基于ajax的api,已经把ajax简单地封装到底了:
1.自动填表栏
代码:
<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
代码:
<ui:mapviewer id="mapviewerx" center="#{mapbean.mappoint}" info="#mapbean.mapmarker}"
markers="#{mapbean.locations}" style="height: 500px; width: 700px"/>
3. 选值填入的输入框
4. 文档编辑器

5. 类yahoo的打分按钮
代码:
<ui:rating id="rating" maxgrade="5" includenotinterested="true" includeclear="true"
hovertexts="#{ratingbean.ratingtext}" notinterestedhovertext="not interested"
clearhovertext="clear rating" grade="#{ratingbean.grade}"/>
6. 日历

7. 表单验证
代码:
<ui:ajaxvalidator messageid="input1" eventhook="onkeypress">
<h:inputtext>
<f:validatelength minimum="3" />
</h:inputtext>
</ui:ajaxvalidator>
8. 上传工具
代码:
<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
闽公网安备 35060202000074号