Support for modal dialog boxes is provided with
Dialog
and is typically used from an
Command
:
class EditCommand extends Command
{
public EditCommand(BHxView view)
{
super(view);
dlg = new EditDialog(this);
}
public void handle(HxOp op) throws Exception
{
if (!dlg.isSubmit(op)) dlg.open(op);
else
{
String name = op.getFormValue("name");
String age = op.getFormValue("age");
BDude dude = (BDude)op.get();
dude.setName(name);
dude.setAge(Integer.parseInt(age));
refresh(op);
}
}
private EditDialog dlg;
}
class EditDialog extends Dialog
{
public EditDialog(Command handler) { super("Edit", handler); }
protected void writeContent(HxOp op) throws Exception
{
BDude dude = (BDude)op.get();
HtmlWriter out = op.getHtmlWriter();
out.w("<table>");
out.w("<tr>");
out.w(" <td>Name</td>");
out.w(" <td><input type='text' name='").w(op.scope("name"));
out.w("' value='").w(dude.getName()).w("'/></td>");
out.w("</tr>");
out.w("<tr>");
out.w(" <td>Age</td>");
out.w(" <td><input type='text' name='").w(op.scope("age"));
out.w("' value='").w(dude.getAge()).w("'/></td>");
out.w("</tr>");
out.w("</table>");
}
}
Copyright © 2000-2019 Tridium Inc. All rights reserved.