> Html html = new Html()
>          .addElement(new Head()
>          .addElement(new org.apache.ecs.html.Title("Entry Form")))
>          .addElement(new Body()
>             .setBgColor(HtmlColor.SILVER)
>             .addElement(today)
>             .addElement(scrolling)
>             .setOnLoad("scrollMsg()")

> "Can't invoke a method on a Void"

The setOnLoad method returns a void and the addElement method can only
accept an object, not a void which is what gets returned if the final
method for your Body object is setOnLoad. There are two ways around
this.

One is to use the addAttribute method to set your onLoad function
instead of using the setOnLoad. I know it's not as intuitive, but as
addAttribute returns Element instead of void you can use it. So your
code would be:

          .addElement(new Body()
             .setBgColor(HtmlColor.SILVER)
             .addElement(today)
             .addElement(scrolling)
             .addAttribute("onLoad","scrollMsg()")

The only other option is to first declare the Body section as it's own
variable using one of the following two options:

Body myBody = new Body();
myBody.setBgColor(HtmlColor.SILVER);
myBody.addElement(today);
myBody.addElement(scrolling);
myBody.setOnLoad("scrollMsg()");

Or, as some prefer, declare all the parts of the body that return Body
within the creation of the variable and set any attributes that return
void or Element after the creation of the variable:

Body myBody = (new Body()
  .setBgColor(HtmlColor.SILVER)
  .addElement(today)
  .addElement(scrolling)
);
myBody.setOnLoad("scrollMsg()");

Hope that helps,
David


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to