/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ecbeta.view.tag;

import static com.ecbeta.common.constants.Constants.*;
import com.ecbeta.common.core.AbstractController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
/**
 *
 * @author Ronghai Wei <ronghai.wei@outlook.com>
 */
public class FormTag  extends AbstractTag{

    public FormTag() {
        super();
    }
    
    
    private AbstractController controller;

    public AbstractController getController() {
        return controller;
    }

    public void setController(AbstractController controller) {
        this.controller = controller;
    }

    public AbstractController getWorker() {
        return controller;
    }

    public void setWorker(AbstractController worker) {
        this.controller = worker;
    }
 
 
    @Override
    public int doEndTag() throws JspException {
        int returnValue = super.doEndTag();
        this.println("</form>", "</div>"); 
        return returnValue;
    }

    @Override
    public int doStartTag() throws JspException {
        super.doStartTag();
        HttpServletRequest request = this.getRequest();
        
        StringBuilder sb = new StringBuilder();
        sb.append("<div id='form' > ").append("\n");
        sb.append("<form class='formnomargin' name='").append(controller.getFORM_NAME()).append("'  id='").append(controller.getFORM_NAME()).append("'  action='").append(this.getContextPath()).append("/"+CORE_SERVLET+"' method='post'>").append("\n");
        //sb.append("     <input type='hidden' name='" + REQUEST_WORKER + "' id='" + REQUEST_WORKER + "' value='").append(worker.getClass().getName()).append("' />").append("\n");
        //sb.append("     <input type='hidden' name='" + SRC_JSP + "' id='" + SRC_JSP + "' value='").append(worker.getJspGoto()).append("' />").append("\n");
        sb.append("     <input type='hidden' name='"+BTN_OPTION+"' id='"+BTN_OPTION+"'  value='' /> ").append("\n");
        sb.append("     <input type='hidden' name='" + NAV_TIERS + "' id='" + NAV_TIERS + "' value='").append(controller.getNavTier()).append("' />").append("\n");

        this.println(sb); 
        return EVAL_BODY_INCLUDE;
    } 
    
    @Override
    public void release() { 
        this.controller = null;
        super.release();
    }
 
}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ecbeta.view.tag;

import static com.ecbeta.common.constants.Constants.*;
import com.ecbeta.common.core.AbstractController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
/**
 *
 * @author Ronghai Wei <ronghai.wei@outlook.com>
 */
public class FormTag  extends AbstractTag{

    public FormTag() {
        super();
    }
    
    
    private AbstractController controller;

    public AbstractController getController() {
        return controller;
    }

    public void setController(AbstractController controller) {
        this.controller = controller;
    }

    public AbstractController getWorker() {
        return controller;
    }

    public void setWorker(AbstractController worker) {
        this.controller = worker;
    }
 
 
    @Override
    public int doEndTag() throws JspException {
        int returnValue = super.doEndTag();
        this.println("<div style='display:none;'> <input name='__nothing' id='__nothing' value='__nothing' /> </div>");
        this.println("</form>", "</div>"); 
        return returnValue;
    }

    @Override
    public int doStartTag() throws JspException {
        super.doStartTag();
        HttpServletRequest request = this.getRequest();
        
        StringBuilder sb = new StringBuilder();
        sb.append("<div id='form' > ").append("\n");
        sb.append("<form class='formnomargin' name='").append(controller.getFORM_NAME()).append("'  id='").append(controller.getFORM_NAME()).append("'  action='").append(this.getContextPath()).append("/"+CORE_SERVLET+"' method='post'>").append("\n");
        //sb.append("     <input type='hidden' name='" + REQUEST_WORKER + "' id='" + REQUEST_WORKER + "' value='").append(worker.getClass().getName()).append("' />").append("\n");
        //sb.append("     <input type='hidden' name='" + SRC_JSP + "' id='" + SRC_JSP + "' value='").append(worker.getJspGoto()).append("' />").append("\n");
        sb.append("     <input type='hidden' name='"+BTN_OPTION+"' id='"+BTN_OPTION+"'  value='' /> ").append("\n");
        sb.append("     <input type='hidden' name='" + NAV_TIERS + "' id='" + NAV_TIERS + "' value='").append(controller.getNavTier()).append("' />").append("\n");

        this.println(sb); 
        return EVAL_BODY_INCLUDE;
    } 
    
    @Override
    public void release() { 
        this.controller = null;
        super.release();
    }
 
}

Fix press enter will auto submit when only one input show