Custom Tag with ImageAnchor and FormSubmit? - Weblogic

This is a discussion on Custom Tag with ImageAnchor and FormSubmit? - Weblogic ; package tag_handlers; import com.bea.wlw.netui.tags.html.Anchor; import com.bea.wlw.netui.tags.html.Button; import com.bea.wlw.netui.tags.html.Form; import com.bea.wlw.netui.tags.html.ImageAnchor; import com.bea.wlw.netui.tags.html.TextBox; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; import java.lang.reflect.*; import java.util.ArrayList; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; public class TestTag extends javax.servlet.jsp.tagext.BodyTagSupport { ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Custom Tag with ImageAnchor and FormSubmit?

  1. Custom Tag with ImageAnchor and FormSubmit?

    package tag_handlers;

    import com.bea.wlw.netui.tags.html.Anchor;
    import com.bea.wlw.netui.tags.html.Button;
    import com.bea.wlw.netui.tags.html.Form;
    import com.bea.wlw.netui.tags.html.ImageAnchor;
    import com.bea.wlw.netui.tags.html.TextBox;
    import java.beans.BeanInfo;
    import java.beans.IntrospectionException;
    import java.beans.Introspector;
    import java.beans.PropertyDescriptor;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import java.lang.reflect.*;
    import java.util.ArrayList;
    import javax.servlet.ServletRequest;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletRequestWrapper;

    public class TestTag extends javax.servlet.jsp.tagext.BodyTagSupport
    {
    private String _Name = "";
    private String _Action = "";

    public void setAction(String sAction)
    {
    this._Action = sAction;
    }

    public void setName(String sName)
    {
    this._Name = sName;
    }

    public int doStartTag() throws JspException
    {
    try
    {
    PageContext oPageContext = pageContext;
    String sContextPath =
    ((HttpServletRequest)oPageContext.getRequest()).ge tContextPath();

    Form oForm = new Form();
    oForm.setAction(_Action);
    oForm.setPageContext(oPageContext);
    oForm.setParent(this);

    oForm.doStartTag();
    BodyContent oBodyContent = oPageContext.pushBody();
    oForm.setBodyContent(oBodyContent);
    oForm.doInitBody();


    ImageAnchor oImageAnchor = new ImageAnchor();
    oImageAnchor.setAction(_Action);
    oImageAnchor.addParameter("Type", "ok");
    oImageAnchor.setAlign("center");
    oImageAnchor.setBorder("0");
    oImageAnchor.setSrc(sContextPath +
    "/resources/images/ok.gif");
    oImageAnchor.setFormSubmit(true);
    oImageAnchor.setPageContext(oPageContext);
    oImageAnchor.setParent(this);
    oImageAnchor.doStartTag();
    oImageAnchor.setBodyContent(oBodyContent);
    oImageAnchor.doInitBody();

    while (oImageAnchor.doAfterBody() ==
    BodyTagSupport.EVAL_BODY_AGAIN) {}
    oImageAnchor.doEndTag();
    oImageAnchor.release();

    while (oForm.doAfterBody() ==
    BodyTagSupport.EVAL_BODY_AGAIN) {}
    oPageContext.popBody();
    oForm.doEndTag();
    oForm.release();
    }
    catch (Exception e) {
    e.printStackTrace();
    throw new JspException(e);
    }

    return SKIP_BODY;
    }


    }

    This is the JSP file.

    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
    <%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
    <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
    <%@ taglib uri="taglib.tld" prefix="custom"%>


    <br /> Web Application Page<br />











    When I run this code the output looks like this:


    >


    <br /> Web Application Page<br />



    action="/TopLinkTestWeb/pageflows/iscrip/grid/updateAction.do"
    method="post">
    href="/TopLinkTestWeb/pageflows/iscrip/grid/updateAction.do?Type=ok"> src="/TopLinkTestWeb/resources/images/ok.gif" align="center"
    border="0">







    Question?
    Where is the form submit part? I see that if I drag the ImageAnchor
    from the palette and the view the source when I run the there is a
    onclick that was added to the ImageAnchor.

    How can I do also create the script in my Custom tag?




  2. Re: Custom Tag with ImageAnchor and FormSubmit?

    Hi
    I found my own problem.

    The oImageAnchor.setParent(this); is wrong is should be the parent of
    the form oImageAnchor.setParent(oForm);

    Thanks


+ Reply to Thread