Thanks Kevin.

See enclosed.  Extremely simple template example.

The taglibs seem to work in that the individual .jsps are located and
rendered as html, it's just that the order of execution seems off.  

The individual pieces of html are at the top, and the template is on the
bottom?


Is this it?  

I modified the following code per some instructions, I was having other
issues before I made these changes (couldn't get to linked pages in
strutsexample app)

org.apache.struts.taglib.html.FormTag.doEndTag



thanks

-Rick

 /**
     * Render the end of this form.
     *
     * @exception JspException if a JSP exception has occurred
     */
    public int doEndTag() throws JspException {

        // Remove the page scope attributes we created
/*      pageContext.removeAttribute(Constants.BEAN_KEY,
                                    PageContext.REQUEST_SCOPE);
COMMENTED OUT!!!!
        pageContext.removeAttribute(Constants.FORM_KEY,
                                    PageContext.REQUEST_SCOPE);
*/
        // Remove the page scope attributes we created
        pageContext.removeAttribute(Constants.BEAN_KEY);
        pageContext.removeAttribute(Constants.FORM_KEY);


        // Render a tag representing the end of our current form
        StringBuffer results = new StringBuffer("</form>");

        // Render JavaScript to set the input focus if required
        if (focus != null) {
            String tempFocus = focus;
            StringBuffer refocus = new StringBuffer("[");
            if (tempFocus.indexOf("[") > 0) {
                StringTokenizer st = new StringTokenizer(tempFocus, "[");
                if (st.countTokens() == 2) {
                    tempFocus = st.nextToken();
                    refocus.append(st.nextToken());
                }
            }
            results.append("\r\n");
            results.append("<script language=\"JavaScript\"");
            results.append(" type=\"text/javascript\">\r\n");
            results.append("  <!--\r\n");
            results.append("    document.forms[\"");
            results.append(name);
            results.append("\"].elements[\"");
            results.append(tempFocus);
            results.append("\"]");
            if (refocus.length() > 1) {
                results.append(refocus.toString());
            }
            results.append(".focus()\r\n");
            results.append("  // -->\r\n");
            results.append("</script>\r\n");
        }

        // Print this value to our output writer
        JspWriter writer = pageContext.getOut();
        try {
            writer.print(results.toString());
        } catch (IOException e) {
            throw new JspException
                (messages.getMessage("common.io", e.toString()));
        }

        // Continue processing this page
        return (EVAL_PAGE);

    }






>        <<templateExample.txt>> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, September 25, 2001 7:22 PM
> To:
> Cc:   Vaillancourt, Richard
> Subject:      Re: template taglib example
> 
> 
> **************************************************************************
> 
> Note: This e-mail is subject to the disclaimer contained at the bottom
> of this message.
> 
> **************************************************************************
> :
> 
> Not sure your template look like, but you may try to use flush="true" in
> your template.
> 
> There is a broken JSP container in Websphere 3.5 not sure 4.0 fixed it or
> not.
> 
> Regards
> Kelvin
> 
> 
> :
> **************************************************************************
> ******
> 
> The information transmitted in this message and attachments (if any)
> is intended only for the person or entity to which it is addressed.  
> The message may contain confidential and/or privileged material.  
> Any review, retransmission, dissemination or other use of, or taking 
> of any action in reliance upon this information, by persons or entities
> other than the intended recipient is prohibited.  
> 
> If you have received this in error, please contact the sender and delete
> this
> e-mail and associated material from any computer.
> 
> The intended recipient of this e-mail may only use, reproduce, disclose or
> distribute the information contained in this e-mail and any attached
> files,
> with the permission of CGU Insurance.
> 
> This message has been scanned for viruses and cleared by MailMarshal.
> 
> ********************************************************************
> :

/////////////////////////////////////////////////////////////
        this is the url

http://localhost:8080/strutsexample/index-struts-template.jsp



/////////////////////////////////////////////////////////////
        this is /strutsexample/index-struts-template.jsp

<%@ taglib uri='/WEB-INF/struts-template.tld' prefix='template' %>
<template:insert template='/testTemplate.jsp'>
<template:put name='title' content='Templates' direct='true'/>
<template:put name='sidebar' content='/testSidebar.jsp' />
<template:put name='header' content='/testHeader.jsp' />
<template:put name='content' content='/testContent.jsp'/>
<template:put name='footer' content='/testFooter.jsp' />
</template:insert>


/////////////////////////////////////////////////////////////
        this is the testTemplate.jsp

<%@ taglib uri='/WEB-INF/struts-template.tld' prefix='template' %> 
<html><head><title><template:get name='title'/></title></head>
<body > <table border="1">
<tr valign='top'><td><template:get name='sidebar'/></td>
<td><table border="1">
<tr><td><template:get name='header'/></td></tr>
<tr><td><template:get name='content'/></td></tr>
<tr><td><template:get name='footer'/></td></tr>
</table>
</td>
</tr> </table>
</body></html>

/////////////////////////////////////////////////////////////
        this is testSidebar.jsp
<font size='5'><a name="top">Topics</a></font><p>
<table width='145'>
    <tr><td><a href='introduction.jsp'>
        Introduction </a></td></tr>
    <tr><td><a href='using.jsp'>
        Using Templates </a></td></tr>
    <tr><td><a href='optional.jsp'>
        Optional Content </a></td></tr>
    <tr><td><a href='more.jsp'>
        ... and more ...</a></td></tr>
  </table></p>
<%
/*
Specify navigational links for this application.
*/
%>

/////////////////////////////////////////////////////////////
        this is testHeader.jsp

<table>
<tr>
<td>"Header"</td>
</tr>
</table>

/////////////////////////////////////////////////////////////
        this is testContent.jsp
<table>
<tr>
<td>"Content"</td>
</tr>
</table>

/////////////////////////////////////////////////////////////
        this is testFooter.jsp

<table>
<tr>
<td>"Footer"</td>
</tr>
</table>

/////////////////////////////////////////////////////////////
        this what gets rendered on the browser, the templated table comes last... 
starting at html...
        I tried this as straight @include directives and it worked fine

<font size='5'><a name="top">Topics</a></font><p>
<table width='145'>
    <tr><td><a href='introduction.jsp'>
        Introduction </a></td></tr>
    <tr><td><a href='using.jsp'>
        Using Templates </a></td></tr>
    <tr><td><a href='optional.jsp'>
        Optional Content </a></td></tr>
    <tr><td><a href='more.jsp'>
        ... and more ...</a></td></tr>
  </table></p>


<table>
<tr>
<td>"Header"</td>
</tr>
</table>
<table>
<tr>
<td>"Content"</td>
</tr>
</table>


<table>
<tr>
<td>"Footer"</td>
</tr>
</table> <html><head><title>Templates</title></head>
<body > <table border = "1">
<tr valign='top'><td></td>
<td><table border="1">
<tr><td></td></tr>
<tr><td></td></tr>
<tr><td></td></tr>
</table>
</td>
</tr> </table>
</body></html>









Reply via email to