3 Replies Latest reply on Sep 3, 2004 4:28 PM by vebs

    nukes block example

    vebs Newbie

      Hi All

      i succesfully setup nukes with eclipse. now i want example to create block/module and deploy them on jboss.

      please do not give this url in your response as they are of no use




        • 1. Re: nukes block example
          jae Master

          the "template" and "rss" modules are relatively simple and server as good starter examples.

          if you have a general overall understanding of what a sar archive is and how to create one through the build process (look at the build.xml examples in the other modules) you should be ok.

          there is also the project page that has a brief howto and any documentation in the wiki. feel free to contribute back and construct your own simple howto for others who wish to create a module.

          • 2. Re: nukes block example
            Matthieu Chase Heimer Newbie

            That url that you don't want is probably the best howto right now. I'd recomment generating the javadoc html for the core and nukes source code from the Nukes source code and then just looking at the existing modules.

            If you want a basic block example here's one I did when I first was figuring out Nukes. I didn't even use ant much less eclipse so this should apply to anyone.

            Source for a basic block that just displays the current date:

            package org.jboss.nukes.examples;
            import org.jboss.nukes.block.BlockSupport;
            import org.jboss.nukes.html.Page;
            import java.util.GregorianCalendar;
            import java.util.Calendar;
            public class DateBlock extends BlockSupport {
             public void render(Page page) {
             GregorianCalendar calendar = new GregorianCalendar();
             String month = null;
             case 0: month = "January";
             case 1: month = "February";
             case 2: month = "March";
             case 3: month = "April";
             case 4: month = "May";
             case 5: month = "June";
             case 6: month = "July";
             case 7: month = "August";
             case 8: month = "September";
             case 9: month = "October";
             case 10: month = "November";
             case 11: month = "December";
             page.print(month + " " + calendar.get(Calendar.DATE) + " " + calendar.get(Calendar.YEAR));

            To compile you'll need to include nukes-lib.jar in your classpath. nukes-lib.jar can be found inside of the nukes.ear.

            You'll also need a xml configuration file called jboss-service.xml. The contents of it should be:

            <?xml version="1.0" encoding="UTF-8"?>
             <attribute name="Title">Current Date</attribute>
             <attribute name="Side">0</attribute>
             <attribute name="Weight">0</attribute>
             <attribute name="Collapsable">false</attribute>

            You'll need to package both these pieces into a Service ARchive(a .sar file) which can be created with jar. Just put the class file (including the needed directory structure for it's package) into the base of the archive and put the jboss-service.xml into the META-INF folder in the archive. One you've done that just copy the archive to $JBOSS_HOME/server/default/nukes

            • 3. Re: nukes block example
              vebs Newbie

              Hello Chase,

              Yes I got sucesseded in running above example.

              THANKS very much.

              In future i may need ur help.