Menu

Hello World!

Marc Magon
Attachments
HelloWorldServlet.java (1630 bytes)

Welcome to JWebSwing!

Try out this Hello World Application to get started :)
You can run it as an interactive Servlet, or simply run as a main application to check out the HTML Rendered.

Want to see it in production mode? p.setTinyHTML(true);!


@FormattingCSS(Background_Color$ = ColourNames.Aqua)
public class HelloWorldServlet extends JWebSwingServlet
{
private final Page p = new Page("Hello World Application!");

@Override
public Page getPage(String sessionId)
{
    Body b = new Body();
    p.add(b);
    b.add("Hello World!");
    return p;
}

public static void main(String...args)
{
    HelloWorldServlet servlet = new HelloWorldServlet();
    System.out.println(servlet.getPage("No Session").renderHTML().toString());
}

@Override
public AppenderSkeleton getLogAppender()
{
    return null;
}

}

How about making it a little interactive?

@Override
public Page getPage(String sessionId)
{
Body b = new Body();
p.add(b);
Paragraph para = new Paragraph("Hello World!");
para.addEvent(new ClickEvent()
{
@Override
public void onClick(Component calledFromComponent, String value)
{
para.setBackgroundColour(ColourNames.Blue);
}

    });
    b.add(para);
    return p;
}

Whatcha think?