Edwin Goei's Blog

Component Authoring for Creator

Thursday Mar 02, 2006

I'm currently working on component authoring for Creator. What does this mean? Creator was designed to be an easy-to-use tool to write webapps. It comes with a built-in set of JavaServer Faces (JSF) components, but users often want more. So I've been writing documentation for component developers on how to create components that work well with Creator. This process involves writing the runtime parts that will be deployed to an app server, plus the design-time parts, and then packaging all the parts into a complib file. Currently, the runtime parts need to follow some guidelines so they can be rendered well in the tool. See the latest draft version of the component authoring document for more information. An official version of this document should be published soon on the Creator web site.

As part of this effort, I've written a sample complib and have just added a new more complex prototype component to illustrate how one can add resources such as JavaScript and CSS files to a complib. One of my responsibilities was to fix problems in the current Creator built-in calendar component. I realized that this component needed to be refactored so I thought I would write a new version of a popup calendar as a real-world example. So I started by doing a survey of existing date-picker and popup calendar type of components on the web and came up with a set of requirements. I think I have come up with an improved prototype which can be the basis of a new product-quality popup calendar. Feel free to modify it and extend it to fit your needs. Below are some screenshots.

Basic popup calendar using default view root locale

Popup calendar using zh_CN locale

Popup calendar embedded in a table

I'd like to know if this is useful to you. Feel free to post comments or email me.

[20] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg
Comments:

It is very good. Can u please send me the sample code for this popup calendar. Thanks in advance

Posted by kishan on June 08, 2006 at 11:52 PM PDT #

The popup calendar has been updated since this blog entry. You may be able to find the old original code by following the link to the component authoring article. The new updated version has been added to the AJAX complib and the source code is freely available from the bpcatalog project of java.net at https://bpcatalog.dev.java.net/. I haven't finished writing up this information yet, though, but plan to soon.

Posted by Edwin Goei on June 09, 2006 at 10:37 AM PDT #

Edwin, I have been reading the documentation you wrote regarding component authoring. I am not sure how to go about creating my own component lib. Should I be using JSC to create the comp lib. I not sure how the build.xml included in the sample-simple-2.2.1-src.zip ran be run in Creator. Is it best to uses netbeans to create the component lib?

Posted by godfrey on June 26, 2006 at 05:28 PM PDT #

Yeah, the article this blog entry points to needs updating. The popup calendar sample has been updated and is now part of the open source bpcatalog tree on java.net. I haven't had time to update the article yet, though. Feel free to check out the "ui" subtree of the bpcatalog CVS tree which contains the source to popup calendar amoung other components. Creator is used to build webapps and not that good at writing components so you can use your favorite tool to build the JSF component. The plans I've heard are to support Creator-style visual form development to netbeans.

Posted by Edwin Goei on June 26, 2006 at 05:48 PM PDT #

I solved an issue with the bpcatalog build file by adding the j2ee.home propoerty tag to the build.xml files. <!-- =================== Initialize Property Values ====================== --> <!-- Configure user property values --> <!-- NOTE: User *must* define "j2ee.home" to point at an installation of SJSAS 8.x PE (such as the one Creator installs) --> <property name="j2ee.home" value="C:\Program Files\Sun\Creator2_1\SunAppServer8"/> <property file="build.properties"/> <property file="../build.properties"/> <property file="${user.home}/build.properties"/> I am still interested in an example with the code generation.

Posted by godfrey on June 28, 2006 at 03:57 PM PDT #

Great, I'm glad you figured it out as I remember running into the same problems but don't remember how I resolved it. The generator has some bugs so the AJAX components don't use it, but the downside is that you must manually keep different files in sync. As I understand it the current plans are to migrate the code generator into an APT plug-in for Java 5. I tried to encourage people to make the generator source code public but it hasn't happened yet. Thanks for helping to debug the steps for getting things to build. I'll use it when I write the updated docs.

Posted by Edwin Goei on June 28, 2006 at 04:41 PM PDT #

Edwin I have not been able to get my component rendering in design. Also the JSP page is not updated with JSF tags for my component. I have created a BeanInfo class folling the popupcalendar example. I can drag and drop my component but only the java file gets updated the JSP is unchanged. Also my component shows up as a non-visible component in the designer navigator. I am not sure about the sun-faces-config.xml. There are lots of references in the docs about requiring a sun-faces-config.xml yet the popupcalendar example works without this file. Please let me know if the sun-faces-config.xml file is necessary. Also is there a way to get debug information from the JSC IDE. Is there a command line arg to make the logging more verbose?

Posted by godfrey on June 30, 2006 at 04:49 PM PDT #

Are you using the latest sample from the bpcatalog tree on java.net? That is the code I would look at. I thought you got that to work from a previous comment. The sample that is part of the wiki page has not yet been updated and is obsolete. The sun-faces-config.xml file is not used in the latest version IIRC. I think you should be able to access the IDE log from a menu or look at the file externally. Alternatively, I think it's possible to run it in a cygwin window and redirect stderr to a file. You may need to add "-J-Dnetbeans.logger.console=true" on the command line.

Posted by Edwin Goei on June 30, 2006 at 05:38 PM PDT #

Edwin thanks for the reply: I realise the problem is my render is not getting called. I added the following code to my render and the exception was never thrown in JSC. <code> public void encodeEnd(FacesContext context, UIComponent component) throws IOException { // assert component instanceof AjaxTextField; boolean foo = true; if(foo) { IOException e = new IOException("foo"); throw e; } [is there a way to write to the JSC logging in the render? ] </code> I am now wondering if my faces-config.xml and .tld is in the correct place or correctly names. How does JSC find the faces-config.xml as there is no reference to this config file in the complib-config.xml?

Posted by godfrey on June 30, 2006 at 09:48 PM PDT #

The faces-config.xml file is part of JSF and is read by the JSF implementation at runtime. Creator also simulates this at design-time. I think if you write to stdout or stderr via println(), the output will go to the Creator log and also to the appserver log when the app is deployed. One thing that may help is to run a debugger and set a breakpoint in your encodeEnd() method. You can debug the appserver or Creator itself, because Creator will call the renderer just like an appserver does. Creator does not simulate all of what happens, though. For example the tag handler does *not* get called.

Posted by Edwin Goei on July 02, 2006 at 12:53 AM PDT #

Edwin how does Creator locate the faces-config.xml for my customer component. I believe that my faces-config.xml location in not correct. Is there a standard that says the faces-config.xml needs to be in directory "foo/bar"? If there is any documentation about where this and other files must be located and how files must be named for Creator design time. Please don't tell me Creator locatese the faces-config.xml using the the same method as an app server. In an app server (like tomcat) the faces-config.xml's location can be specified in a web.xml file.

Posted by godfrey on July 04, 2006 at 09:03 AM PDT #

The faces-config.xml file should be under WEB-INF/. I don't know if it's possible to change this via a web.xml init parameter without checking the JSF spec. Deploying to tomcat may take additional steps. Using the bundled appserver should be automatic. Creator tries to simulate at design-time what a container like an appserver or a servlet container does at runtime. It does this by using a modified JSF implementation internally and faking some things.

Posted by Edwin Goei on July 04, 2006 at 09:21 AM PDT #

So to debug a custom component, you could try getting a project to run in a container like the bundled appserver. You can look at the server log to see problems and use a debugger to debug it. Then if that is working, you can fix the Creator design-time problems by looking at the Creator log file and debugging Creator.

Posted by Edwin Goei on July 04, 2006 at 09:26 AM PDT #

Quote from email:

I should have been more clear: Where should the faces-config.xml be located in the complib? (In the complib there is no WEB-INF. )

The complib file is a package file like a war file. It is only used by Creator currently. Creator expands the file into a directory structure just like a server does to a war file. The expanded tree should have at least one runtime jar. The runtime jar contains a WEB-INF/ which contains the faces-config.xml. This follows the JavaServer Faces spec. See complib spec for details about the complib format.

Posted by Edwin Goei on July 05, 2006 at 10:05 AM PDT #

Ya this popup calendar is very useful please send me source code of this.

Posted by swati on August 30, 2006 at 11:46 PM PDT #

Hi Edwin, the popup calendar works in normal form for me but when i start integrating it with my table component.. it doesn't work ( well it works for one particular row only ) I think it is because when i select the popup calendar for one particular row.. the Calendar sticks to that rowId and wont never work for any other row. i Believe this is a javascript problem Please help. Thank you Very Much.

Posted by willy on August 31, 2006 at 12:04 AM PDT #

I'm planning to update the sample popup calendar as a complib soon. I'll post a blog entry when I'm done.

Posted by Edwin Goei on August 31, 2006 at 10:36 AM PDT #

Hi Ed, I've a question for you. Can I use an external JSF library (ICEFaces, ADF) within Java Studio Creator? Are the visible within palette?

Posted by Angelo on October 27, 2006 at 03:16 AM PDT #

Ideally we should be able to do this and this is a long term goal, but in reality it probably will not be supported for a while because of various technical problems.

Posted by Edwin Goei on October 27, 2006 at 08:02 AM PDT #

Hi,
This is Thamarai and I want that code part for pop up calender component. If possible, please send it to me immediately.

Posted by Thamarai on November 05, 2007 at 08:28 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed