public static void FORMS()
{
ItsNatDocument itsNatDoc = null;
ItsNatComponentManager componentMgr = itsNatDoc.getItsNatComponentManager();
final ItsNatHTMLForm formComp = (ItsNatHTMLForm)componentMgr.createItsNatComponentById("formId");
formComp.setEventListenerParams("submit",false,CommMode.XHR_SYNC,null,null,-1);
formComp.setEventListenerParams("reset",false,CommMode.XHR_SYNC,null,null,-1);
EventListener evtListener = new EventListener()
{
public void handleEvent(Event evt)
{
System.out.println(evt.getCurrentTarget() + " " + evt.getType());
EventTarget currentTarget = evt.getCurrentTarget();
if (currentTarget == formComp.getHTMLFormElement())
{
if (evt.getType().equals("submit"))
{
System.out.println("Submit canceled");
evt.preventDefault(); // Cancels the submission, only works in SYNC mode
}
// reset is not cancellable
}
else // Link
{
formComp.reset(); // submit() method is defined too
}
}
};
formComp.addEventListener("submit",evtListener);
formComp.addEventListener("reset",evtListener);
ItsNatHTMLAnchor linkComp = (ItsNatHTMLAnchor)componentMgr.createItsNatComponentById("linkId");
linkComp.addEventListener("click",evtListener);
}