跳至主要内容

博文

目前显示的是标签为“NetBeans”的博文

JSF 2.2: Embrace CDI?

JSF 2.2: Embrace CDI? CDI 1.0 is part of Java EE 6, it is the standard Dependency Injection specification for Java EE platform. But unfortunately, JSF 2.0 which is also part of Java EE 6 did not adopt CDI as its Dependency Injection/IOC container, but invented its IOC container. Dependency injection in JSF 2.0 In the package javax.faces.bean , there are several annotations provided. You can annotate your JSF backend bean with annotation @ManagedBean and put it in a reasonable scope( @ApplicationScoped , @RequestScoped , @SessionScoped , @ViewScoped , @NoneSopced ). @ManagedBean(name="foo") @RequestScoped public class FooBean{ } The attribute name specified in the @ManagedBean can be accessed via EL in facelets views. You can inject it in other beans via @ManagedProperty . @ManagedBean(name="bar") @RequestScoped public class BarBean{ @ManagedPropertiy("foo") FooBean foo; } In JSF 2.0, it also supports to annotate the fiel...

JSF 2.2: HTML5 Support

JSF 2.2: HTML 5 Support No doubt HTML 5 is the hottest topic in web development in these years. Besides a series of new tags are added, the form element support is also improved. The type attribute of input element can be text , email , number , range , url , date etc. Ideally, a browser could provide native validation for these input tags.(but this feature support is very different between browsers). JSF 2.0 In JSF 2.0, some attributes of HTML 5 form elements can not be rendered correctly in the standard JSF input components. For example, <input type="email" can not be rendered by <h:inputText type="email" . omnifaces fixes the issue, and adds basic HTML5 form elements support by a extened Html5RenderKitFactory . What you need to do is declare a Html5RenderKitFactory in the faces-config.xml. <factory> <render-kit-factory>org.omnifaces.renderkit.Html5RenderKitFactory</render-kit-factory> </factory> Now,...

JSF 2.2: File Upload

JSF 2.2: File Upload Before 2.2, you have to use Richfaces , Primefaces like JSF components to provide file upload feature. Or you must write a custom file upload component yourself. Luckily this long waiting feature was finally added in JSF 2.2. An example In JSF 2.2, the FacesServlet is annotated with @MultipartConfig , which causes JSF can handle multpart form data correctly. @MultipartConfig public final class FacesServlet implements Servlet {} The following is a simple facelets page, which includes a h:form and h:inputFile components. <h:form enctype="multipart/form-data"> <h:inputFile id="file" value="#{fileUploadBean.file}" /> <h:commandButton value="Upload" action="#{fileUploadBean.upload()}"/> </h:form> The new inputFile component is provided for file upload purpose. The usage is simple. Like other input components, put it into a h:form, the enctype attribute must be cha...

JSF 2.2: Theme

JSF 2.2: Theme Richfaces and Primefaces have theme support, it is an attractive feature of the skin-able JSF components projects. JSF 2.2 introduces a new feature named Resource Library Contracts which supports to apply different resources(css and js) and facelets template at runtime. contracts resources files can be placed in /contracts folder under the web application root or /META-INF/contracts on classpath. Using contracts in a web application The following is an example of contracts resources structure in a web application. /contracts /default /css defautl.css cssLayout.css template.xhtml /alternative /css defautl.css cssLayout.css template.xhtml There are two contracts defined in the project, default and alternative . The following is the content of /contracts/default/template.xhtml . <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html> <ht...

JSF 2.2: View Action

JSF 2.2: View Action JSF 2.2 introduced a new view action feature, which had been existed in JBoss Seam 2 and Seam 3 for a long time. In fact, JSF 2.2 copied the Seam 3 view action exactly. An example An example is better than thousands of words. @Model public class ViewActionBean { @Inject Logger log; private String flag="page1"; public String init(){ log.info("call init"); switch(flag){ case "page1": return "page1"; default: return "page2"; } } public String getFlag() { return flag; } public void setFlag(String flag) { this.flag = flag; } } Create a facelets view and use a view action to invoke the init method. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:f="...

Getting Started with Apache Click and NetBeans IDE

Note: this post is from my project wiki pages, please read https://github.com/hantsy/click4nb/wiki/Getting-Started-with-Apache-Click-and-NetBeans-IDE for the newest version. If you have some suggestion or find some errors, please file an issue. Thanks. After moved from Google Code, I have cleaned the codes and just released a new version of click4nb , which was tested against the stable NetBeans IDE 7.2. Installation Following the steps in Installation wiki page to install click4nb into your NetBeans IDE. Create a web project with Apache Click Support Create a Web Application in NetBeans is very easy, follow the following steps to create one for yourself. Click the New Project button or click "File/New Project" menu from main menu in NetBeans IDE. In the popup New Project dialog, select Java Web in the Categories list, and Web Application in the "Projects", click Next button. In the Name and Location dialog, input the project related info, such...

Click4nb 1.1.1 is available now

Click4 nb 1.1.1 is available for downloading now. I have uploaded the file to Google Code and NetBeans Plugin center. Get it and try. This release does not provide more new features but an improvement for Page class hyperlink support( Issue 1 ). Currently, click4 nb works well on NetBeans 6.8. I will move my development envoriment ot NetBeans 6.9 for the next version. In the next version, I will try my best to implement the following features. 1. Add click 2.2 support ( Cllick team has just release the first RC of Click 2.2), update the libary to Click 2.2 and improve the Content Assistance for 2.2. 2. Intergrate Cayenne Modeler into NetBeans IDE , add a action to open Cayenne file directly in NetBeans IDE . 3. Configuration for Cayenne ORM framework and Click intergration . Feel free to submit your feedback by email( hantsy@tom.com ) or leave message on this blog, you can also report your bug in the issue tracker.

Maven support in NetBeans 6.7 m2 ...en

NetBeans has released the second milestone product some days ago. There are many articles on PlanetNetBeans( http://www.planetnetbeans.org ) which were talking about the newest features NetBeans 6.7 will bring. Maven support is a highlight feature of them. Many peoples have praised the Maven support in NetBeans 6.7. I am a maven fan, but after I tried it, I was disappointed. Maven support is an incomplete work now. As described on NetBeans wiki, it supports JEE and Java Web project creation now. I found this functionality is only a short-circuit of the normal "Maven Project". In the second step of the wizard, it only provide a extra Java EE version option. In my idea, it must support: target server selection, project relation (parent Maven module and child Maven module) settings and web framework configuration. For "Web project", ideally, in the project definition panel , it must provide a "Add to existed Enterprise Application" option to add current ma...

A new registeration problem occured...

NetBeans 6.5 patch 2 is available now. As the release note declared , the previous JBoss 5 registration problem is fixed in this patch. This means You can add a JBoss Application Server in Services Windows directly , as you add other app server. 1. Start NetBeans 6.5 , and open the Services Windows. 2.Right click the "Server" node , select Add Server in context menu. Unfortunately, I got a NullPointerException. I try to do this in another way . Open Server manager from Tools->Servers menu , click add Server button and then encounter the same problem. This is a bug reported in NetBeans bugzilla , as report #123180 . It is awfully boring. Update: From the www.planetnetbeans.org , a blog entry named " NetBeans, JDK Update 12 and Server Registrati " reports the same problem. The reason is that NetBeans 6.5 runs on the newest JDK 6 update 12. I've just updated it to update 12. Downgrade jdk to update 11 or wait for the ...

Registering JBoss 5 GA in NetBeans 6.5 under Fedora 10

JBoss 5 is GA for some days, but NetBeans 6.5 dose not support JBoss 5.0.0 GA. I use google and find the solution to fix the problem. Follow this blog entry, Registering JBoss 5.0 in NetBeans 6.5. Simple copy several jars from JBoss common lib directory to the instance lib directroy. Enter the JBoss home directory and enter common/lib directory. [hantsy@localhost jboss-5.0.0.GA]cd common/lib [hantsy@localhost lib]cp jboss-javaee.jar jboss.jar jbosssx.jar jmx-adaptor-plugin.jar jnpserver.jar log4j.jar ../../server/default/lib/ It is simple. Now you can add JBoss 5 to the Server node in NetBeans Services Windows. But I encountered another problem under Fedora 10. When I start JBoss 5 from NetBeans Service panel. It failed with the following error message. The transaction service port is used by another application. [hantsy@localhost ~]$ sudo netstat -apl|grep 4713 [sudo] password for hantsy: tcp 0 0 *:4713 *:* LISTEN 24723...

My wishlist in future NetBeans.

NetBeans 7.0 is only a improved version , it will not bring many new features to us. May be the version should be 6.6 or 6.5.1. 1. Clean Code . Many codes in NetBeans are too old. Why not clear them and start at a new point. Sun and the NetBeans team are too care about the API compatibility. I think as a major version upgrade , like 6.5 to 7.0 , it can begin at a new point. Provide a more clear API strategy to keep the API compatibility , I think it is good to the module developer. For example , the minor version upgrade, like 6.0 to 6.1, only make the API more stable and usable and mark the unused API to deprecated but do not remove them. Thus all modules agianst 6.0 can work well on all 6.x version. When a major upgrade, like 6.5 to 7.0, remove the old code marked with Deprecated annotations in last version. Add the new usable API to the main trunk. Ajust the base infrastructure to make it more powerful. 2. Improve UI operation . I would like using the Swing (metal) UI when I...

NetBeans 6.1 发布了

在短暂的延期后,NetBeans 6.1 终于发布了。 一起来关注一下NetBeans 6.1的一些激动人心的特性。 首先 NetBeans 6.1 在性能上有大幅提升,启动明显比以前快很多,编辑器的响应速度也大幅度提升,Navigator的解析速度也明显加快。 这在老外的博客上作了详尽的描述,请参考这里P erformance improvements in NetBeans 6.1 。 另外,6.1也为企业级开发提供了便利,现在流行的应用框架Spring, Hibernate, Struts都已经得到NetBeans 官方支持。Spring在下载包中已经内置了。Hibernate只要点击几下,从PluginPortal中安装即可。 经过重新设计,NetBeans 6.1提供了近乎完美的JavaScript支持。这为开发Web 2.0程序作好了准备,这里提供了一个 Javascirpt的开发演示 的教程。 在Web Service 支持也得到了增强,支持了Apache aisx,直接集成了SoupUI的调试工具,正式支持Rest风格的WebService开发。 语言方面加入了PHP(现在处于开发阶段,这个目标是在下一个版本正式提供),现在下载站点已经提供了一个开发版本(Early Access),你可以 http://www.netbeans.org 下载一个完整的PHP开发环境。 数据库方面直接集成了MySQL,这可能是Sun收购MySQL之后,产品集成上的首个体现吧。 NetBeans 的下一个版本是6.5 ,计划年底提供,请参考NetBeans 的 Roadmap 。 一个主要是的目标是提供PHP开发环境,另外会完全重新设计数据库的支持。这是值得期待的。另外也提到要提供Javascript的debug功能。 具体细节,请参考NetBeans wiki内容,请参考 http://wiki.netbeans.org/NetBeans65 。