星期三, 十月 21, 2009
Click for NetBeans plugin 1.0 is avai...
I am very pleased to announce that the first version of Click for netBeans plugin is available now. You can get it from the Kenai.com or NetBeans plugin portal.
Click is a simple, but effective and component based web framework, it hosts on the Apache as a incubator project.
This plugin bring basic Click support for NetBeans IDE.
It includes the following features:
1、Project creation wizard.
2、Click Page creation wizard(the interface cloned clickide).
3、Provide basic error checks,hyperlink,code templates,code completion,refacotoring in click.xml file.
4、Also provide hyperlink,code templates,code completion in menu component configuration file.
5、Switch between Page Template, Page Class , Page properties quickly。
This project is open source under GPL, it hosts on kenai.com.
Homepage:http://kenai.com/projects/nbx
User Forum:http://kenai.com/projects/nbx/forums/user-forum
Mail List:http://kenai.com/projects/nbx/lists
Bugzilla: http://kenai.com/bugzilla/buglist.cgi?product=nbx&order=Importance&limit=25
Svn Repository: http://kenai.com/projects/nbx/sources/subversion/show
Thank Rohan Ranade for helping me during the development progress.
Try it now.
星期三, 八月 26, 2009
NetBeans Struts2 plugin updates
NetBeans Struts 2 plugin (http://nbstruts2support.dev.java.net)is not updated for a long time. I checkout the source code and made some modification to the latest NetBeans IDE 6.7.
1.Update Struts library to the latest stable version 2.1.6
2.Update to the latest web framework API。
3.Redesigned configuration panel and provide more flexible configuration options
4.Other modification to Struts 2.1.
Download here :https://dl.getdropbox.com/u/201666/nbstruts2.tar.bz2
Struts 2.1 provides next generation Filter to process request , and also provides a new optional Servlet .
If you like choose Struts Servlet to process request , you can check "Servlet" radio box in the "Reuqest processed by" section in the "Main" tab.
This will generate some code like the following.
<servlet>
<servlet-name>struts2servlet</servlet-name>
<servlet-class>org.apache.struts2.dispatcher.ng.servlet.StrutsServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>struts2servlet</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
If you would like use Filter to process request which is recommended by Struts , it will generate some code in web.xml.
<filter>
<filter-name>struts2</filter-name>
<filter-class>apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
In the new Struts 2.1 , the StrutsPrepareAndExecuteFilter instead of DiispactherFilter. StrutsPrepareAndExecuteFilter has two variants, StrutsPrepareFilter and StrutsExecuteFilter. If you use other Filter together, especially the Sitemesh
Filter,StrutsPrepareFilter will do some clean action.
In the Plugin Support tab, there are some Struts2 plugin configuration are provided.
If you select Filter to process reqeust and use sitemesh filter at the same time.
It will generate the following code in web.xml for you.
<filter>
<filter-name>struts2prepare</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter</filter-class>
</filter>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
<filter>
<filter-name>struts2execute</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2execute</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
In the Main tab, provide a Development Mode checkbox . If you check it , it will add a constant to the struts configuration file. These options will benefit debuging struts2 application in the development phase.
<constant name="struts.devMode" value="true"/>
<constant name="struts.configuration.xml.reload" value="true"/>
If the Spring support checkbox is selected, it will add constant in the struts cofiguration.
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>
Struts will use Spring as object factory to create Struts object, include Action , Interceptor etc.
Beside this , it will add some configuration in the web.xml. It also create a new empty Spring configuration file.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Convention puglin is a new plugin shipped with Struts 2.1, it adopt much concept from other plugin. Using this plugin , you can Java 5 annotation instead of xml configuration.
Convention has a optional parameter, You can input the actions package name , this will help struts at runtime to detect the Action class.
For Struts2 beginner, the best learning path may be learngin by example. If you select Create Example Application check box, it will create a simple example which is from the Strust source code.
星期四, 八月 13, 2009
Another NetBeans plugin updated - RichFaces
This a small personal update for RichFaces plugin for NetBeans (http://nbrichfacessupport.dev.java.net) .
Modification includes:
1. Update richfaces to 3.3.1.GA.
2. Add skin selector to the configuration panel.
Then it will generate the following code in web.xml .
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>japanCherry</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
download here :RichFaces
星期三, 八月 12, 2009
I updated two NetBeans plugins
I checked out nbwicketsupport (http://nbwicketsupport.dev.java.net) of
branch nb_67.
And made a slight modification on it for the Wicket 1.4 release version.
1. update wicket libaray to 1.4 release .
2. make wicket framework detect works.
3. update example (Login, Pizaa) application (Using filter instead of
servlet, remove jasypt lib dependency )
Some problem I encountered.
1. In a maven web project , add Wicket support causes NetBeans dead.
Kill and restart NetBeans, I found it configured correctly.
2. I tried to add some code to disable Wicket configuration and display
the configured information on the Framework panel ( in the Project
properties) after adding it to the Web project( Struts support use this
style). But I do not how to get the "HomePage" from project ( code about
it is commented).
The second is the Stripes plugin (http://code.google.com/p/stripes4netbeans/). Small modification includes:
1. Replace the configuration panel for essential configuration.
2. Add "ActionResolver.Packages" configuration.
3. make Stripes framework detect works.
I encountered the same problem in a maven web project described before.
These are not official updates.
Download: nbwicket.tar.bz2 stripes4netbeans
星期日, 五月 10, 2009
Meet FishCAT Member Hantsy Bai
I expressed my thought about Glassfish and how to spread it in China community.
The link is here(http://blogs.sun.com/judy/entry/testing).
星期一, 三月 02, 2009
Maven support in NetBeans 6.7 m2 ...en
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 maven project as a module to the parent module(a enterprise application). And support specifying the target runtime server , it should support adding suitable server which are defined in "Servers" node in "Services" windows , and it is better to support adding embeded server plugin(jetty). Web framework configuration support is a must for web project.
For "Enterprise project", beside server selection and Java EE version options , it should support creating "Web Module"," EJB Module" and "App Client Module" in the same wizard, and let user can modify the default name and location of children modules(war, ejb, ear).
For "EJB project", like web projct without web framework selection.
Another problem is the "Add library" dialog which occurs when you right click the "Library" node in the Project view. The new "add library" dialog maybe merged from the "Add Library" and "Find Dependency" in NetBeans 6.5. But I dislike this feature , I preferred using the query-result style ( like "Find Dependency" in NetBeans 6.5) view. The three fields in "Add library" dialog are implemented the "Code Completation" feature , maybe some body like it. But on my machine , It is too slow. When I input first character, I must took some minutes waiting the code completion context menu, after it displayed , then I could input the second character. Beside this, not everybody can remember the first part of group id , artifact id of every maven artifacts. For example, if you want add "common logging" dependency to your project, it is a apache project , you maybe guess the group id is "org.apache.commons". But you are wrong , it is "commons". In this way , I wasted much time on guessing the group id and at last I had to give up , and turned to use the Maven repository browser to search it. Obviously this feature is no use for me. My suggestion is remove it from NetBeans 6.7, use the simple query-style view instead it. In this approach , it must search the keyword( the word user input in the query field) in group id , artifact id , package name and full class name of all artifacts in the whole maven repository. So the NetBeans GUI maybe looks united, in the "Navigate" menu, all "Go To" dialogs use this simple UI style.
The third small defect I found is the "Files" windows in Maven project , it displays the logic name of some nodes , not the real system directory name.
星期六, 二月 28, 2009
Hack JBoss JDocbook Maven Plugin
Jeff Yu noticed my post on javaeye forum and suggested me to use JBoss JDocbook maven plugin(http://www.jboss.org/maven-jdocbook-plugin), and complained it is lack of Chinese support at the same time. Given my docbook experience , if you want to use Apache FOP to render PDF and dream beautiful Chinese font support , you must customsize the FOP config file.
When I checked out the JDocbook source code and read the core code about pdf render, I found it have no way to use customized FOP config file.
I decided to resovle the problem , add serval lines of code , I made a patch soon. This patch has been submitted to JBoss , please see https://jira.jboss.org/jira/browse/MPJDOCBOOK-19(beside a patch, you can also get the modified pdf.xsl file and my customsized fop config file) .
This patch do the following thing in code.
1. Expose a option of the Apache FOP config file path in the configuration class - Options.
2. In the PDFRender class, use FopFactory to load this config file.
After apply the patch to jdocbook 2.1.2 , you can use a custom fop config file now.
As a example to test the patch, I use the translated JBoss Cache Core User Guide docbook source as a sample. You can get it from the kava community(http://www.kava.org.cn) which translate the JBoss Cache Core User Guide into Chinese.
Modify the pom.xml, add a userConfig element in options tag. The following is the User Guide profile in details.
<profile>
<!-- This profile generates Javadocs and the UserGuide, FAQs and Tutorial in the "package" phase. -->
<id>User Guide</id>
<activation>
</activation>
<properties>
<!-- override to generate javadocs in the "package" phase -->
<javadocPhase>package</javadocPhase>
</properties>
<build>
<plugins>
<!-- the docbook generation plugin for the user guide -->
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-plugin</artifactId>
<version>2.1.2.patched</version>[1]
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-docbook-xslt</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-jdocbook-style</artifactId>
<version>1.1.0</version>
<type>jdocbook-style</type>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>0.95</version>[2]
</dependency>
<dependency>[3]
<groupId>avalon-framework</groupId> <artifactId>avalon-framework</artifactId> <version>4.1.5</version> </dependency> <dependency> <groupId>avalon-framework</groupId> <artifactId>avalon-framework-impl</artifactId> <version>4.1.5</version> </dependency>
</dependencies>
<executions>
<execution>
<id>userguide_zh_CN</id>
<phase>package</phase>
<goals>
<goal>resources</goal>
<goal>generate</goal>
</goals>
<configuration>
<sourceDocumentName>master.xml</sourceDocumentName>
<sourceDirectory>${basedir}/src/main/docbook/userguide/zh_CN</sourceDirectory>
<imageResource>
<directory>${basedir}/src/main/docbook/images</directory>
</imageResource>
<cssResource>
<directory>${basedir}/src/main/docbook/css</directory>
</cssResource>
<targetDirectory>${basedir}/target/docbook/userguide_zh_CN</targetDirectory>
<formats>
<format>[4] <formatName>pdf</formatName> <stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource> <finalName>userguide_zh_CN.pdf</finalName> </format>
<format>
<formatName>html</formatName>
<stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
<format>
<formatName>html_single</formatName>
<stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
<finalName>index.html</finalName>
</format>
</formats>
<options>
<xincludeSupported>false</xincludeSupported>
<userConfig>src/main/resources/fop.xconf</userConfig>[5]
</options>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
[2]I used the latest fop.
[3]Add avalon dependency due to a exception in compile progress.
[4]Use my modified pdf.xsl to render pdf.
[5]Specified the customsized fop config file location which include my favorite Chinese font config.
Let's look at the modified pdf.xsl ( which is provide in the jbossorg-docbook-xslt). This purpose is to use my favorite Chinese font in font family .
Find the following section.
<xsl:param name="title.font.family">
<xsl:call-template name="pickfont-sans"/>
</xsl:param>
<xsl:param name="body.font.family">
<xsl:call-template name="pickfont-sans"/>
</xsl:param>
<xsl:param name="monospace.font.family">
<xsl:call-template name="pickfont-mono"/>
</xsl:param>
<xsl:param name="sans.font.family">
<xsl:call-template name="pickfont-sans"/>
</xsl:param>
<xsl:param name="body.font.family">'SimSun'</xsl:param>
<xsl:param name="title.font.family">'SimHei'</xsl:param>
<xsl:param name="monospace.font.family">'SimKai'</xsl:param>
<xsl:param name="sans.font.family">'SimSun'</xsl:param>
The best way is redefine the pikfont-sans, pikfont-mono template definition, it is friendly to multilanguage support. As a lazy guy , I use Chinese font directly.
You might notice that I use a single Chinese font definition in font family instead of a series of font name , because FOP can not correctly process the font family if you use other none Chinese font together. This problem may be fixed in the snapshot version.
Now you can generate PDF .