include jsp tags

I am having a problem relacing the include file of let's call it a

header.jsp in a menu page named menu.jsp.

So in my header.jsp file let's say I do something simple like

<table>

<tr><td><jato:href name="first">First Option

</jato:href></td></tr></table>

and so on....

And in my main.jsp I have a simple include at the top of my page

like so

<html

><body>

<%include file=header.jsp%>

etc.

Now when JRun 3.0 makes the include replacement, it seems to have a

problem where it tells me

Servlet error 500

com.iplanet.jato.view href : taglib navigation not found

BUT when I take out the jato tags in the include file...I can get

JRun to make the replacement perfectly....

Does anyone else have this problem and if so how did you get around

it?

[1001 byte] By [Guest] at [2007-11-25 9:29:40]
# 1

Hi Eric--

> I am having a problem relacing the include file of let's call it a

> header.jsp in a menu page named menu.jsp.

The first thing I noticed is that it appears that you are trying to do a

run-time include instead of a translation-time include of header.jsp.

Run-time includes are like a nested request for the included resource--the

request is sent to the included object and the result of its execution is

inlined in the result.

That's fine if you have a full JATO page you want to include, but it looks

like you're trying to include a JATO fragment which you want to be parsed in

the context of main.jsp. For that, you need to do a translation-time

include:

<%@ include file="header.jsp" %>

This takes the content of header.jsp and includes it in main.jsp before it

is translated into a servlet. The embedded JATO tags in header.jsp should

then be translated properly in the context of main.jsp.

I don't have much personal experience with JRun, so I can't speak directly

to the error message you're getting. But, testing in Resin

(<a href="http://www.caucho.com">http://www.caucho.com</a>) and Tomcat verifies that the translation-time

include works as expected, whereas a run-time include (of a fragment) fails.

Give this suggestion a try and let us know what happens.

Todd

Guest at 2007-7-1 16:35:55 > top of Java-index,Development Tools,Java Tools...
# 2

Craig & Eric--

(If you're not interested in the resolution to the problem Craig posted,

please skip ahead to the section in which I describe the preferred technique

for including headers and other common content in a JATO page. This

discussion is very important because I introduce the concept of "view

compostion", in which JATO pages are composed of modular and reusable view

components. This is one of the most powerful new features of JATO, and a

capability that simply wasn't possible in NetDynamics.)

Posted Problem Resolution

-

Craig & Eric, from what I can tell, you are both trying to include a full

view bean in a parent page at translation time. This is not possible, as

you can see from the compiler errors you get. There are collisions when

multiple top-level tags are included in the same JSP.

When I said earlier that you needed to use a translation-time include

instead of a run-time include, I was assuming that you were trying to

include a fragment of HTML/JSP in the parent page. By fragment, I mean HTML

or JSP content that does not declare a view bean or form, but rather

references views contained within the parent view bean. If you want to

include a full page (JSP + ViewBean) in another page, then you'd need to use

a run-time include. A run-time include temporarily pauses the rendering of

the current page, and sends the full request to the included page as if it

were a separate client request. The resulting content from the included

page is inlined into the parent page's content, and processing of the parent

page then continues.

Now I realize after thinking about it a bit that we may not have

sufficiently provided for full page includes because of some late-breaking

changes in the request context handling. After some basic testing, it

appears that if you try to include one JATO page in another by referencing

the JSP, the included page will cause a class cast exception to occur.

There may also be problems because the request context on the included page

will not have been set. In any case, full JATO page inclusion looks like

it's an issue we're going to have to address with some fixes before it will

work properly. My apologies. (One workaround if this is necessary is to

make the included view bean a child view of the parent view bean. I won't

go into that however).

How to Include Common Content

Now, on to the discussion of the preferred way of including common content

in a JATO page. Let's say you have a common header you want to include in

one or more of your JATO pages. Because of the issue I noted above, and the

fact that the header is not really independently displayable, you don't want

to do a run-time include (which, remember, would necessitate including a

full JATO page).

Instead, you should include the header as an HTML/JSP fragment using a

translation-time include. Depending on whether your header has dynamic

information, you can do one of two things. If the header is just static

content and/or set of links, you can just reference the HTML fragment in the

parent HTML directly, and you won't need any kind of view or view bean to

back it, or any reference to anything in JATO.

If you need some dynamic info in the header, like the module URL for a link,

you can reference the parent page's view bean for this information by simply

including references to the parent page's implicit JSP variables (viewBean,

currentVIew, and currentTiledView). For example:

Parent JSP:

-

<jsp:useBean id="viewBean" class="..." scope="request"></jsp:useBean>

<jato:useViewBean className="..." fireChildDisplayEvents="true">

...

<%@ include file="MyInclude.jsp" %>

...

</jato:useViewBean>

-

Included content (MyInclude.jsp):

-

... viewBean.getRequestContext().getModuleURL() ...

-

The final HTML with the included content would then look like this:

-

<jsp:useBean id="viewBean" class="..." scope="request"></jsp:useBean>

<jato:useViewBean className="..." fireChildDisplayEvents="true">

...

... viewBean.getRequestContext().getModuleURL() ...

...

</jato:useViewBean>

-

MyInclude.jsp will be inlined in the parent JSP before it is translated to a

servlet. Note that it does not include the full HTML tags normally found in

an HTML file--there are no <html>, <head>, or <body> tags because it is not

expected to be used outside of an include page. In effect, this is the

equivalent of a server-side include (SSI).

Now, if you need truly dynamic info in the header, like say you want to

display the user's name and SSN, then you'd likely want to embed a child

view in the parent view bean which will encapsulate & provide the necessary

information. This is in contrast to actually making these fields direct

children of the the parent view bean, which would be a tedious and error

prone task on every page you wanted to include this information. Let me try

to contrast these two approaches with a diagram of parent-child

relationships:

Here's the bad way:

ParentViewBean (ViewBean)

|

+-- UserFirstName (StaticTextField)

|

+-- UserSSN (StaticTextField)

In this situation, you'd need to provide the logic to populate these fields

in every view bean on which they appeared. This is tedious and essentially

eliminates the "common"-ness of the content (this is also what NetDynamics

forced people to do).

Now, the better way:

ParentViewBean (ViewBean)

|

+-- MyHeaderView (MyHeaderView.java)

|

+-- UserFirstName (StaticTextField)

|

+-- UserSSN (StaticTextField)

In the better way, you can see that the header information is encapsulated

in an instance of "MyHeaderView", which is a subclass of ContainerViewBase

or one of the other ContainerView subtypes. The population of the data

fields is encapsulated in that view, and the parent view need not know

anything about what's actually being displayed by that view.

Thus, you can see that MyHeaderView, in conjunction with a snippet of JSP

content in a companion file, is completely modular and can be embedded in

any parent view bean on which you want the header to appear. The only

requirement is then to include MyHeaderView as a child view of the parent

view bean, and to include the correct JSP content that references that child

view.

The included JSP content would now look something like this:

--

<jato:view name="MyHeaderView">

<table>

<tr><td>... <jato:staticText name="UserFirstName"/> ...</td></tr>

<tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>

</table>

</jato:view>

--

If we now included this content in the parent JSP from further above, we get

the following as the JSP content before it is translated into a servlet:

-

<jsp:useBean id="viewBean" class="..." scope="request"></jsp:useBean>

<jato:useViewBean className="..." fireChildDisplayEvents="true">

...

<jato:view name="MyHeaderView">

<table>

<tr><td>... <jato:staticText name="UserFirstName"/> ...</td></tr>

<tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>

</table>

</jato:view>

...

</jato:useViewBean>

-

Ultimately, this technique is called "view compostion" or "view

aggregation", and is one of the major new features of JATO. You can now

define reusable view components and embed them in multiple view containers,

on the same page or on different pages. Each page acts as a frame, in which

you provide the contents from modular components. Using this technique, you

can develop reusable view classes and chunks of JSP that can be arbitrarily

combined into complex pages.

I know this is a long and rambling discussion, but I hope I've made myself

at least partly clear. I'm more than happy to clarify anything or elaborate

more. Please let me know.

Todd

--

Todd Fast

Senior Engineer

Sun/Netscape Alliance

<a href="/group/SunONE-JATO/post?protectID=189233080150035131169232031248130090006 048031198039130252055210">todd.fast@e...</a>

Guest at 2007-7-1 16:35:55 > top of Java-index,Development Tools,Java Tools...
# 3

Hi Mike,

Both of the jsp files (pgHelp.jsp and pgFooter.jsp)

are in the same folder. I removed the IPP/ipp portion in the

include directive but still giving the same err.

iam using Allair Jrun 3.0.

Here is the intermediary generated Jsp file

/

/ Generated by JRun, do not edit

import javax.servlet.*;

import javax.servlet.http.*;

import javax.servlet.jsp.*;

import javax.servlet.jsp.tagext.*;

import allaire.jrun.jsp.JRunJSPStaticHelpers;

public class jrun__IPP__ipp__pgHelp2ejsp13 extends

allaire.jrun.jsp.HttpJSPServlet implements

allaire.jrun.jsp.JRunJspPage

{

private ServletConfig config;

private ServletContext application;

private Object page = this;

private JspFactory __jspFactory = JspFactory.getDefaultFactory();

public void _jspService(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, java.io.IOException

{

if(config == null) {

config = getServletConfig();

application = config.getServletContext();

}

response.setContentType("text/html; charset=ISO-8859-1");

PageContext pageContext = __jspFactory.getPageContext(this,

request, response, null, true, 8192, true);

JspWriter out = pageContext.getOut();

HttpSession session = pageContext.getSession();

try {

out.print("\r\n\r\n");

IPP.ipp.pgHelpViewBean viewBean = (IPP.ipp.pgHelpViewBean)

pageContext.getAttribute("viewBean", PageContext.REQUEST_SCOPE);

if(viewBean == null) {

if(JRunJSPStaticHelpers.getAndSetBean(pageContext,

"viewBean", IPP.ipp.pgHelpViewBean.class

, PageContext.REQUEST_SCOPE, 3)) {

viewBean = (IPP.ipp.pgHelpViewBean)pageContext.getAttribute

("viewBean", PageContext.REQUEST_SCOPE);

} else {

viewBean = (IPP.ipp.pgHelpViewBean)pageContext.getAttribute

("viewBean", PageContext.REQUEST_SCOPE);

}

}

pageContext.setAttribute("viewBean",viewBean);

out.print("\r\n");

com.iplanet.jato.taglib.UseViewBeanTag useViewBean__4_1 =

(com.iplanet.jato.taglib.UseViewBeanTag)

JRunJSPStaticHelpers.createTagHandler(pageContext,

"com.iplanet.jato.taglib.UseViewBeanTag");

useViewBean__4_1.setPageContext(pageContext);

useViewBean__4_1.setParent(null);

useViewBean__4_1.setClassName("IPP.ipp.pgHelpViewBean");

int useViewBean__4_1_startVal = useViewBean__4_1.doStartTag();

JRunJSPStaticHelpers.checkStartVal

("com.iplanet.jato.taglib.UseViewBeanTag",useViewBean__4_1_startVal,Bo

dyTag.EVAL_BODY_INCLUDE,4);

if(useViewBean__4_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {

com.iplanet.jato.view.ContainerView currentView =

(com.iplanet.jato.view.ContainerView)pageContext.getAttribute

("currentView");

;

com.iplanet.jato.view.TiledView currentTiledView =

(com.iplanet.jato.view.TiledView)pageContext.getAttribute

("currentTiledView");

;

out.print("\r\n<HTML>\r\n<HEAD><!--jato:text name=\"stTemp\"

fireDisplayEvents=\"true\" escape=\"true\" /--><!-- Added Temporarily

by ravindran on 8th jan 2001 -->\r\n");

com.iplanet.jato.taglib.TextFieldTag textField__7_1 =

(com.iplanet.jato.taglib.TextFieldTag)

JRunJSPStaticHelpers.createTagHandler(pageContext,

"com.iplanet.jato.taglib.TextFieldTag");

textField__7_1.setPageContext(pageContext);

textField__7_1.setParent(useViewBean__4_1);

textField__7_1.setSize("20");

textField__7_1.setMaxLength("20");

textField__7_1.setFireDisplayEvents("true");

textField__7_1.setName("tbUserID");

textField__7_1.doStartTag();

if(textField__7_1.doEndTag() == Tag.SKIP_PAGE) {

if(true) return;

}

out.print("\r\n<TITLE>pgHelp</TITLE>\r\n</HEAD>\r\n<body BGCOLOR=

\"white\" bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=

\"#800080\" alink=\"#FF0000\">\r\n");

com.iplanet.jato.taglib.FormTag form__11_1 =

(com.iplanet.jato.taglib.FormTag)JRunJSPStaticHelpers.createTagHandler

(pageContext, "com.iplanet.jato.taglib.FormTag");

form__11_1.setPageContext(pageContext);

form__11_1.setParent(useViewBean__4_1);

form__11_1.setMethod("post");

form__11_1.setName("pgHelp");

int form__11_1_startVal = form__11_1.doStartTag();

JRunJSPStaticHelpers.checkStartVal

("com.iplanet.jato.taglib.FormTag",form__11_1_startVal,BodyTag.EVAL_BO

DY_INCLUDE,11);

if(form__11_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {

out.print("\r\n");

}

if(form__11_1.doEndTag() == Tag.SKIP_PAGE) {

if(true) return;

}

out.print("\r\n");

com.iplanet.jato.taglib.UseContainerViewTag view__1_1 =

(com.iplanet.jato.taglib.UseContainerViewTag)

JRunJSPStaticHelpers.createTagHandler(pageContext,

"com.iplanet.jato.taglib.UseContainerViewTag");

view__1_1.setPageContext(pageContext);

view__1_1.setParent(null);

view__1_1.setName("IPP.ipp.pgFooterViewBean");

int view__1_1_startVal = view__1_1.doStartTag();

JRunJSPStaticHelpers.checkStartVal

("com.iplanet.jato.taglib.UseContainerViewTag",view__1_1_startVal,Body

Tag.EVAL_BODY_INCLUDE,1);

if(view__1_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {

currentView = (com.iplanet.jato.view.ContainerView)

pageContext.getAttribute("currentView");

;

currentTiledView = (com.iplanet.jato.view.TiledView)

pageContext.getAttribute("currentTiledView");

;

com.iplanet.jato.view.ContainerView

IPP.ipp.pgFooterViewBean = (com.iplanet.jato.view.ContainerView)

pageContext.getAttribute("IPP.ipp.pgFooterViewBean");

;

out.print("\r\n<hr color=red size=2>\r\nfrom new_footer.jsp in

IPP/ipp directory\r\n<font size=\"-2\" face=\"Arial\"><i>Send

comments to <a href=\"mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134 026100218183041071221141131142254099102">supportdept@a...</a>\">Any

Company</a></i></font>\r\n<hr color=red size=2>\r\n");

com.iplanet.jato.taglib.HiddenTag hidden__6_1 =

(com.iplanet.jato.taglib.HiddenTag)

JRunJSPStaticHelpers.createTagHandler(pageContext,

"com.iplanet.jato.taglib.HiddenTag");

hidden__6_1.setPageContext(pageContext);

hidden__6_1.setParent(view__1_1);

hidden__6_1.setFireDisplayEvents("true");

hidden__6_1.setName("hdFooter");

hidden__6_1.doStartTag();

if(hidden__6_1.doEndTag() == Tag.SKIP_PAGE) {

if(true) return;

}

out.print("\r\n");

}

if(view__1_1.doEndTag() == Tag.SKIP_PAGE) {

if(true) return;

}

out.print("\r\n");

out.print("\r\n</BODY> \r\n</HTML>\r\n");

}

if(useViewBean__4_1.doEndTag() == Tag.SKIP_PAGE) {

if(true) return;

}

} catch(Throwable t) {

if(t instanceof ServletException)

throw (ServletException) t;

if(t instanceof java.io.IOException)

throw (java.io.IOException) t;

if(t instanceof RuntimeException)

throw (RuntimeException) t;

throw JRunJSPStaticHelpers.handleException(t,

pageContext);

} finally {

__jspFactory.releasePageContext(pageContext);

}

}

public String getServletInfo()

{

return "pgHelp";

}

private static final String[] __dependencies__ =

{"/IPP/ipp/pgHelp.jsp",null};

private static final long[] __times__ = {979720473658L,0L};

public String[] __getDependencies()

{

return __dependencies__;

}

public long[] __getLastModifiedTimes()

{

return __times__;

}

public int __getTranslationVersion()

{

return 14;

}

}

it is generating 2 semicolons automatically..

near pageContext.getAttribute("IPP.ipp.pgFooterViewBean");

regards

ravi

In <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166136 248038136183193071193172194143142">iPlanet-JATO@egroups.com</a>, "Mike Frisino" <<a href="/group/SunONE-JATO/post?protectID=174176219122158198138082063148231088239 026066196217130152150">Michael.Frisino@S...</a>>

wrote:

> Hi Suket,

>

> I just retested something very similar to this in 1.0.

>

> Essentially, i took an existing page which included a tiledView.

> I moved the TiledView jsp block into an entirely separate jsp file.

> I then replace the TiledView jsp block in the original jsp with an

include

> <%@ include file="TiledGetOrders.jsp"%>

>

> It worked like a charm.

>

> So I am not sure what is wrong in your case.

> Could be a jrun bug?

> I have tested in resin 1.2.1

>

> To do proper analysis, we would need to see

>

> 1. The intermediary .java file that the jsp engine creates, and

then tries

> to compile.

> C:/Program

> Files/Allaire/JRun/servers/default/ipp/WEB-

INF/jsp/jrun__IPP__ipp__pgHelp2ej

> sp.java

> Can you send that to us?

>

>

> Incidentally, although we do not think a problem there would cause

the

> compile time error you are seeing,

> i am curious about your file value.

> > <%@ include file="/IPP/ipp/pgFooter.jsp"%>

>

> I did not need to use a qualified file name, although my include

target file

> was in the same directory as the

> page that was including it. What is the file system relationship

between

> your top level page "pgHelp" and the include

> target "pgFooter".

> Are they in same or diff directories?

>

>

> -- Original Message --

> From: <<a href="/group/SunONE-JATO/post?protectID=061075211056175135130082190036">suke t@u...</a>>

> Sent: Tuesday, January 16, 2001 9:42 PM

> Subject: [iPlanet-JATO] Re: include jsp tags

>

>

> > Hi,

> > We tried to follow the steps described by you to have

> > dynamic include in a jsp page.

> >

> > my jsp file content is

> > -

> > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="pgHelp" language="java"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/jato.tld" prefix="jato"%>

> > <jsp:useBean id="viewBean" class="IPP.ipp.pgHelpViewBean"

> > scope="request"></jsp:useBean>

> > <jato:useViewBean className="IPP.ipp.pgHelpViewBean">

> > <HTML>

> > <HEAD>

> > <jato:textField name="tbUserID" size="20" maxLength="20"

> > fireDisplayEvents="true" />

> > <TITLE>pgHelp</TITLE>

> > </HEAD>

> > <body BGCOLOR="white" bgcolor="#FFFFFF" text="#000000"

> > link="#0000FF" vlink="#800080" alink="#FF0000">

> > <jato:form name="pgHelp" method="post">

> > </jato:form>

> > <%@ include file="/IPP/ipp/pgFooter.jsp"%>

> > </BODY>

> > </HTML>

> > </jato:useViewBean>

> > --

> > This is my pgFooter.jsp

> >

> > <jato:view name="IPP.ipp.pgFooterViewBean">

> > <hr color=red size=2>

> > from new_footer.jsp in IPP/ipp directory

> > <font size="-2" face="Arial"><i>Send comments to <a

> > href="mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134 048139046">supportdept@a...</a>">Any Company</a></i></font>

> > <hr color=red size=2>

> > <jato:hidden name="hdFooter" fireDisplayEvents="true" />

> > </jato:view>

> > --

> > There is no compilation error in pgFooterViewBean and in

> > pgHelpViewBean.

> > How ever iam getting a runtime error,

> >

> > 500 Internal Server Error

> > /ipp/servlet/IPP.ipp.ippServlet:

> >

> > javax.servlet.ServletException: Compilation error occured:

> >

> > allaire.jrun.scripting.DefaultCFE:

> > Errors reported by compiler:C:/Program

> > Files/Allaire/JRun/servers/default/ipp/WEB-

> > INF/jsp/jrun__IPP__ipp__pgHelp2ejsp13.java:105:50:105:50: Syntax:

;

> > expected instead of this token

> > -

> >

> > What could be the reason for this error message?

> > We tried the same thing with another approach, instead of using

> > include directive, we directly copied the code of pgFooter.jsp in

> > pghelp.jsp.

> > even that is giving the same error..

> >

> > -

> > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="pgHelp" language="java"%>

> > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/jato.tld" prefix="jato"%>

> > <jsp:useBean id="viewBean" class="IPP.ipp.pgHelpViewBean"

> > scope="request"></jsp:useBean>

> > <jato:useViewBean className="IPP.ipp.pgHelpViewBean">

> > <HTML>

> > <HEAD>

> > <jato:textField name="tbUserID" size="20" maxLength="20"

> > fireDisplayEvents="true" />

> > <TITLE>pgHelp</TITLE>

> > </HEAD>

> > <body BGCOLOR="white" bgcolor="#FFFFFF" text="#000000"

> > link="#0000FF" vlink="#800080" alink="#FF0000">

> > <jato:form name="pgHelp" method="post">

> > </jato:form>

> >

> > <jato:view name="IPP.ipp.pgFooterViewBean">

> > <hr color=red size=2>

> > from new_footer.jsp in IPP/ipp directory

> > <font size="-2" face="Arial"><i>Send comments to <a

> > href="mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134 048139046">supportdept@a...</a>">Any Company</a></i></font>

> > <hr color=red size=2>

> > <jato:hidden name="hdFooter" fireDisplayEvents="true" />

> > </jato:view>

> >

> > </BODY>

> > </HTML>

> > </jato:useViewBean>

> > --

> > Please give us a feasible solution to solve this problem.

> >

> > Thx

> > Ravi

> >

> >

> > In <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166136 248038136183193071193172194143142">iPlanet-JATO@egroups.com</a>, "Todd Fast" <<a href="/group/SunONE-JATO/post?protectID=101233080150035167169232031248066208071 048">Todd.Fast@S...</a>>

wrote:

> > > Craig & Eric--

> > >

> > > (If you're not interested in the resolution to the problem Craig

> > posted,

> > > please skip ahead to the section in which I describe the

preferred

> > technique

> > > for including headers and other common content in a JATO page.

This

> > > discussion is very important because I introduce the concept of

> > "view

> > > compostion", in which JATO pages are composed of modular and

> > reusable view

> > > components. This is one of the most powerful new features of

JATO,

> > and a

> > > capability that simply wasn't possible in NetDynamics.)

> > >

> > > Posted Problem Resolution

> > > -

> > >

> > > Craig & Eric, from what I can tell, you are both trying to

include

> > a full

> > > view bean in a parent page at translation time. This is not

> > possible, as

> > > you can see from the compiler errors you get. There are

collisions

> > when

> > > multiple top-level tags are included in the same JSP.

> > >

> > > When I said earlier that you needed to use a translation-time

> > include

> > > instead of a run-time include, I was assuming that you were

trying

> > to

> > > include a fragment of HTML/JSP in the parent page. By

fragment, I

> > mean HTML

> > > or JSP content that does not declare a view bean or form, but

rather

> > > references views contained within the parent view bean. If you

> > want to

> > > include a full page (JSP + ViewBean) in another page, then you'd

> > need to use

> > > a run-time include. A run-time include temporarily pauses the

> > rendering of

> > > the current page, and sends the full request to the included

page

> > as if it

> > > were a separate client request. The resulting content from the

> > included

> > > page is inlined into the parent page's content, and processing

of

> > the parent

> > > page then continues.

> > >

> > > Now I realize after thinking about it a bit that we may not have

> > > sufficiently provided for full page includes because of some

late-

> > breaking

> > > changes in the request context handling. After some basic

testing,

> > it

> > > appears that if you try to include one JATO page in another by

> > referencing

> > > the JSP, the included page will cause a class cast exception to

> > occur.

> > > There may also be problems because the request context on the

> > included page

> > > will not have been set. In any case, full JATO page inclusion

> > looks like

> > > it's an issue we're going to have to address with some fixes

before

> > it will

> > > work properly. My apologies. (One workaround if this is

necessary

> > is to

> > > make the included view bean a child view of the parent view

bean.

> > I won't

> > > go into that however).

> > >

> > > How to Include Common Content

> > >

> > >

> > > Now, on to the discussion of the preferred way of including

common

> > content

> > > in a JATO page. Let's say you have a common header you want to

> > include in

> > > one or more of your JATO pages. Because of the issue I noted

> > above, and the

> > > fact that the header is not really independently displayable,

you

> > don't want

> > > to do a run-time include (which, remember, would necessitate

> > including a

> > > full JATO page).

> > >

> > > Instead, you should include the header as an HTML/JSP fragment

> > using a

> > > translation-time include. Depending on whether your header has

> > dynamic

> > > information, you can do one of two things. If the header is

just

> > static

> > > content and/or set of links, you can just reference the HTML

> > fragment in the

> > > parent HTML directly, and you won't need any kind of view or

view

> > bean to

> > > back it, or any reference to anything in JATO.

> > >

> > > If you need some dynamic info in the header, like the module URL

> > for a link,

> > > you can reference the parent page's view bean for this

information

> > by simply

> > > including references to the parent page's implicit JSP variables

> > (viewBean,

> > > currentVIew, and currentTiledView). For example:

> > >

> > > Parent JSP:

> > > -

> > > <jsp:useBean id="viewBean" class="..."

> > scope="request"></jsp:useBean>

> > > <jato:useViewBean className="..." fireChildDisplayEvents="true">

> > > ...

> > > <%@ include file="MyInclude.jsp" %>

> > > ...

> > > </jato:useViewBean>

> > > -

> > >

> > > Included content (MyInclude.jsp):

> > > -

> > > ... viewBean.getRequestContext().getModuleURL() ...

> > > -

> > >

> > > The final HTML with the included content would then look like

this:

> > > -

> > > <jsp:useBean id="viewBean" class="..."

> > scope="request"></jsp:useBean>

> > > <jato:useViewBean className="..." fireChildDisplayEvents="true">

> > > ...

> > > ... viewBean.getRequestContext().getModuleURL() ...

> > > ...

> > > </jato:useViewBean>

> > > -

> > >

> > > MyInclude.jsp will be inlined in the parent JSP before it is

> > translated to a

> > > servlet. Note that it does not include the full HTML tags

normally

> > found in

> > > an HTML file--there are no <html>, <head>, or <body> tags

because

> > it is not

> > > expected to be used outside of an include page. In effect,

this is

> > the

> > > equivalent of a server-side include (SSI).

> > >

> > > Now, if you need truly dynamic info in the header, like say you

> > want to

> > > display the user's name and SSN, then you'd likely want to

embed a

> > child

> > > view in the parent view bean which will encapsulate & provide

the

> > necessary

> > > information. This is in contrast to actually making these

fields

> > direct

> > > children of the the parent view bean, which would be a tedious

and

> > error

> > > prone task on every page you wanted to include this information.

> > Let me try

> > > to contrast these two approaches with a diagram of parent-child

> > > relationships:

> > >

> > > Here's the bad way:

> > >

> > > ParentViewBean (ViewBean)

> > > |

> > > +-- UserFirstName (StaticTextField)

> > > |

> > > +-- UserSSN (StaticTextField)

> > >

> > > In this situation, you'd need to provide the logic to populate

> > these fields

> > > in every view bean on which they appeared. This is tedious and

> > essentially

> > > eliminates the "common"-ness of the content (this is also what

> > NetDynamics

> > > forced people to do).

> > >

> > > Now, the better way:

> > >

> > > ParentViewBean (ViewBean)

> > > |

> > > +-- MyHeaderView (MyHeaderView.java)

> > > |

> > > +-- UserFirstName (StaticTextField)

> > > |

> > > +-- UserSSN (StaticTextField)

> > >

> > > In the better way, you can see that the header information is

> > encapsulated

> > > in an instance of "MyHeaderView", which is a subclass of

> > ContainerViewBase

> > > or one of the other ContainerView subtypes. The population of

the

> > data

> > > fields is encapsulated in that view, and the parent view need

not

> > know

> > > anything about what's actually being displayed by that view.

> > >

> > > Thus, you can see that MyHeaderView, in conjunction with a

snippet

> > of JSP

> > > content in a companion file, is completely modular and can be

> > embedded in

> > > any parent view bean on which you want the header to appear.

The

> > only

> > > requirement is then to include MyHeaderView as a child view of

the

> > parent

> > > view bean, and to include the correct JSP content that

references

> > that child

> > > view.

> > >

> > > The included JSP content would now look something like this:

> > > --

> > > <jato:view name="MyHeaderView">

> > > <table>

> > > <tr><td>... <jato:staticText name="UserFirstName"/>

...</td></tr>

> > > <tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>

> > > </table>

> > > </jato:view>

> > > --

> > >

> > > If we now included this content in the parent JSP from further

> > above, we get

> > > the following as the JSP content before it is translated into a

> > servlet:

> > > -

> > > <jsp:useBean id="viewBean" class="..."

> > scope="request"></jsp:useBean>

> > > <jato:useViewBean className="..." fireChildDisplayEvents="true">

> > > ...

> > > <jato:view name="MyHeaderView">

> > > <table>

> > > <tr><td>... <jato:staticText name="UserFirstName"/>

...</td></tr>

> > > <tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>

> > > </table>

> > > </jato:view>

> > > ...

> > > </jato:useViewBean>

> > > -

> > >

> > > Ultimately, this technique is called "view compostion" or "view

> > > aggregation", and is one of the major new features of JATO. You

> > can now

> > > define reusable view components and embed them in multiple view

> > containers,

> > > on the same page or on different pages. Each page acts as a

frame,

> > in which

> > > you provide the contents from modular components. Using this

> > technique, you

> > > can develop reusable view classes and chunks of JSP that can be

> > arbitrarily

> > > combined into complex pages.

> > >

> > > I know this is a long and rambling discussion, but I hope I've

made

> > myself

> > > at least partly clear. I'm more than happy to clarify anything

or

> > elaborate

> > > more. Please let me know.

> > >

> > > Todd

> > >

> > > --

> > > Todd Fast

> > > Senior Engineer

> > > Sun/Netscape Alliance

> > > <a href="/group/SunONE-JATO/post?protectID=189233080150035131169232031248130208071 048">todd.fast@e...</a>

> >

> >

> > <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166215 146166214017110250006230056039126077176105140127082088124241215002153">iPlane t-JATO-unsubscribe@egroups.com</a>

> >

> >

> >

> >

Guest at 2007-7-1 16:35:55 > top of Java-index,Development Tools,Java Tools...
# 4

Sorry to bother you again, but I couldn't find anything that looked strange

is this file. Can you send us the original file at our personal email

addresses? I'd like to see exactly where the compilation error occurs and

it's not possible with the file inlined here.

<a href="/group/SunONE-JATO/post?protectID=189233080150035131169232031248130090006 048031198039130252055210">todd.fast@e...</a>

<a href="/group/SunONE-JATO/post?protectID=029176219122158198138082061148231088239 026066196077193234150166091061">michael.frisino@s...</a>

Thanks,

Todd

-- Original Message --

From: <<a href="/group/SunONE-JATO/post?protectID=061075211056175135130232175036006239018 ">suket@u...</a>>

Sent: Wednesday, January 17, 2001 2:02

Subject: [iPlanet-JATO] Re: include jsp tags

> Hi Mike,

> Both of the jsp files (pgHelp.jsp and pgFooter.jsp)

> are in the same folder. I removed the IPP/ipp portion in the

> include directive but still giving the same err.

> iam using Allair Jrun 3.0.

>

> Here is the intermediary generated Jsp file

> /

> / Generated by JRun, do not edit

>

>

> import javax.servlet.*;

> import javax.servlet.http.*;

> import javax.servlet.jsp.*;

> import javax.servlet.jsp.tagext.*;

> import allaire.jrun.jsp.JRunJSPStaticHelpers;

>

>

> public class jrun__IPP__ipp__pgHelp2ejsp13 extends

> allaire.jrun.jsp.HttpJSPServlet implements

> allaire.jrun.jsp.JRunJspPage

> {

> private ServletConfig config;

> private ServletContext application;

> private Object page = this;

> private JspFactory __jspFactory = JspFactory.getDefaultFactory();

>

> public void _jspService(HttpServletRequest request,

> HttpServletResponse response)

> throws ServletException, java.io.IOException

> {

> if(config == null) {

> config = getServletConfig();

> application = config.getServletContext();

> }

> response.setContentType("text/html; charset=ISO-8859-1");

> PageContext pageContext = __jspFactory.getPageContext(this,

> request, response, null, true, 8192, true);

> JspWriter out = pageContext.getOut();

> HttpSession session = pageContext.getSession();

>

>

>

>

> try {

>

>

> out.print("\r\n\r\n");

>

> IPP.ipp.pgHelpViewBean viewBean = (IPP.ipp.pgHelpViewBean)

> pageContext.getAttribute("viewBean", PageContext.REQUEST_SCOPE);

> if(viewBean == null) {

> if(JRunJSPStaticHelpers.getAndSetBean(pageContext,

> "viewBean", IPP.ipp.pgHelpViewBean.class

> , PageContext.REQUEST_SCOPE, 3)) {

> viewBean = (IPP.ipp.pgHelpViewBean)pageContext.getAttribute

> ("viewBean", PageContext.REQUEST_SCOPE);

> } else {

> viewBean = (IPP.ipp.pgHelpViewBean)pageContext.getAttribute

> ("viewBean", PageContext.REQUEST_SCOPE);

> }

> }

> pageContext.setAttribute("viewBean",viewBean);

> out.print("\r\n");

>

> com.iplanet.jato.taglib.UseViewBeanTag useViewBean__4_1 =

> (com.iplanet.jato.taglib.UseViewBeanTag)

> JRunJSPStaticHelpers.createTagHandler(pageContext,

> "com.iplanet.jato.taglib.UseViewBeanTag");

> useViewBean__4_1.setPageContext(pageContext);

> useViewBean__4_1.setParent(null);

> useViewBean__4_1.setClassName("IPP.ipp.pgHelpViewBean");

> int useViewBean__4_1_startVal = useViewBean__4_1.doStartTag();

> JRunJSPStaticHelpers.checkStartVal

> ("com.iplanet.jato.taglib.UseViewBeanTag",useViewBean__4_1_startVal,Bo

> dyTag.EVAL_BODY_INCLUDE,4);

> if(useViewBean__4_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {

> com.iplanet.jato.view.ContainerView currentView =

> (com.iplanet.jato.view.ContainerView)pageContext.getAttribute

> ("currentView");

> ;

> com.iplanet.jato.view.TiledView currentTiledView =

> (com.iplanet.jato.view.TiledView)pageContext.getAttribute

> ("currentTiledView");

> ;

> out.print("\r\n<HTML>\r\n<HEAD><!--jato:text name=\"stTemp\"

> fireDisplayEvents=\"true\" escape=\"true\" /--><!-- Added Temporarily

> by ravindran on 8th jan 2001 -->\r\n");

>

> com.iplanet.jato.taglib.TextFieldTag textField__7_1 =

> (com.iplanet.jato.taglib.TextFieldTag)

> JRunJSPStaticHelpers.createTagHandler(pageContext,

> "com.iplanet.jato.taglib.TextFieldTag");

> textField__7_1.setPageContext(pageContext);

> textField__7_1.setParent(useViewBean__4_1);

> textField__7_1.setSize("20");

> textField__7_1.setMaxLength("20");

> textField__7_1.setFireDisplayEvents("true");

> textField__7_1.setName("tbUserID");

> textField__7_1.doStartTag();

> if(textField__7_1.doEndTag() == Tag.SKIP_PAGE) {

>

> if(true) return;

> }

> out.print("\r\n<TITLE>pgHelp</TITLE>\r\n</HEAD>\r\n<body BGCOLOR=> \"white\" bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=

> \"#800080\" alink=\"#FF0000\">\r\n");

>

> com.iplanet.jato.taglib.FormTag form__11_1 =

> (com.iplanet.jato.taglib.FormTag)JRunJSPStaticHelpers.createTagHandler

> (pageContext, "com.iplanet.jato.taglib.FormTag");

> form__11_1.setPageContext(pageContext);

> form__11_1.setParent(useViewBean__4_1);

> form__11_1.setMethod("post");

> form__11_1.setName("pgHelp");

> int form__11_1_startVal = form__11_1.doStartTag();

> JRunJSPStaticHelpers.checkStartVal

> ("com.iplanet.jato.taglib.FormTag",form__11_1_startVal,BodyTag.EVAL_BO

> DY_INCLUDE,11);

> if(form__11_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {

> out.print("\r\n");

> }

> if(form__11_1.doEndTag() == Tag.SKIP_PAGE) {

>

> if(true) return;

> }

> out.print("\r\n");

>

>

> com.iplanet.jato.taglib.UseContainerViewTag view__1_1 =

> (com.iplanet.jato.taglib.UseContainerViewTag)

> JRunJSPStaticHelpers.createTagHandler(pageContext,

> "com.iplanet.jato.taglib.UseContainerViewTag");

> view__1_1.setPageContext(pageContext);

> view__1_1.setParent(null);

> view__1_1.setName("IPP.ipp.pgFooterViewBean");

> int view__1_1_startVal = view__1_1.doStartTag();

> JRunJSPStaticHelpers.checkStartVal

> ("com.iplanet.jato.taglib.UseContainerViewTag",view__1_1_startVal,Body

> Tag.EVAL_BODY_INCLUDE,1);

> if(view__1_1_startVal == BodyTag.EVAL_BODY_INCLUDE) {

> currentView = (com.iplanet.jato.view.ContainerView)

> pageContext.getAttribute("currentView");

> ;

> currentTiledView = (com.iplanet.jato.view.TiledView)

> pageContext.getAttribute("currentTiledView");

> ;

> com.iplanet.jato.view.ContainerView

> IPP.ipp.pgFooterViewBean = (com.iplanet.jato.view.ContainerView)

> pageContext.getAttribute("IPP.ipp.pgFooterViewBean");

> ;

> out.print("\r\n<hr color=red size=2>\r\nfrom new_footer.jsp in

> IPP/ipp directory\r\n<font size=\"-2\" face=\"Arial\"><i>Send

> comments to <a href=\"mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134 026100218183041071221141131142254099102">supportdept@a...</a>\">Any

> Company</a></i></font>\r\n<hr color=red size=2>\r\n");

>

> com.iplanet.jato.taglib.HiddenTag hidden__6_1 =

> (com.iplanet.jato.taglib.HiddenTag)

> JRunJSPStaticHelpers.createTagHandler(pageContext,

> "com.iplanet.jato.taglib.HiddenTag");

> hidden__6_1.setPageContext(pageContext);

> hidden__6_1.setParent(view__1_1);

> hidden__6_1.setFireDisplayEvents("true");

> hidden__6_1.setName("hdFooter");

> hidden__6_1.doStartTag();

> if(hidden__6_1.doEndTag() == Tag.SKIP_PAGE) {

>

> if(true) return;

> }

> out.print("\r\n");

> }

> if(view__1_1.doEndTag() == Tag.SKIP_PAGE) {

>

> if(true) return;

> }

> out.print("\r\n");

>

> out.print("\r\n</BODY> \r\n</HTML>\r\n");

> }

> if(useViewBean__4_1.doEndTag() == Tag.SKIP_PAGE) {

>

> if(true) return;

> }

>

>

> } catch(Throwable t) {

> if(t instanceof ServletException)

> throw (ServletException) t;

> if(t instanceof java.io.IOException)

> throw (java.io.IOException) t;

> if(t instanceof RuntimeException)

> throw (RuntimeException) t;

> throw JRunJSPStaticHelpers.handleException(t,

> pageContext);

>

> } finally {

> __jspFactory.releasePageContext(pageContext);

> }

> }

>

>

>

> public String getServletInfo()

> {

> return "pgHelp";

> }

> private static final String[] __dependencies__ =

> {"/IPP/ipp/pgHelp.jsp",null};

>

> private static final long[] __times__ = {979720473658L,0L};

>

> public String[] __getDependencies()

> {

> return __dependencies__;

> }

>

> public long[] __getLastModifiedTimes()

> {

> return __times__;

> }

>

> public int __getTranslationVersion()

> {

> return 14;

> }

>

> }

>

> it is generating 2 semicolons automatically..

> near pageContext.getAttribute("IPP.ipp.pgFooterViewBean");

>

> regards

> ravi

>

> In <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166136 248038136183193071193172194143142">iPlanet-JATO@egroups.com</a>, "Mike Frisino" <<a href="/group/SunONE-JATO/post?protectID=174176219122158198138082063148231088239 026066196217130152150">Michael.Frisino@S...</a>>

> wrote:

> > Hi Suket,

> >

> > I just retested something very similar to this in 1.0.

> >

> > Essentially, i took an existing page which included a tiledView.

> > I moved the TiledView jsp block into an entirely separate jsp file.

> > I then replace the TiledView jsp block in the original jsp with an

> include

> > <%@ include file="TiledGetOrders.jsp"%>

> >

> > It worked like a charm.

> >

> > So I am not sure what is wrong in your case.

> > Could be a jrun bug?

> > I have tested in resin 1.2.1

> >

> > To do proper analysis, we would need to see

> >

> > 1. The intermediary .java file that the jsp engine creates, and

> then tries

> > to compile.

> > C:/Program

> > Files/Allaire/JRun/servers/default/ipp/WEB-

> INF/jsp/jrun__IPP__ipp__pgHelp2ej

> > sp.java

> > Can you send that to us?

> >

> >

> > Incidentally, although we do not think a problem there would cause

> the

> > compile time error you are seeing,

> > i am curious about your file value.

> > > <%@ include file="/IPP/ipp/pgFooter.jsp"%>

> >

> > I did not need to use a qualified file name, although my include

> target file

> > was in the same directory as the

> > page that was including it. What is the file system relationship

> between

> > your top level page "pgHelp" and the include

> > target "pgFooter".

> > Are they in same or diff directories?

> >

> >

> > -- Original Message --

> > From: <<a href="/group/SunONE-JATO/post?protectID=061075211056175135130082190036">suke t@u...</a>>

> > Sent: Tuesday, January 16, 2001 9:42 PM

> > Subject: [iPlanet-JATO] Re: include jsp tags

> >

> >

> > > Hi,

> > > We tried to follow the steps described by you to have

> > > dynamic include in a jsp page.

> > >

> > > my jsp file content is

> > > -

> > > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="pgHelp" language="java"%>

> > > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/jato.tld" prefix="jato"%>

> > > <jsp:useBean id="viewBean" class="IPP.ipp.pgHelpViewBean"

> > > scope="request"></jsp:useBean>

> > > <jato:useViewBean className="IPP.ipp.pgHelpViewBean">

> > > <HTML>

> > > <HEAD>

> > > <jato:textField name="tbUserID" size="20" maxLength="20"

> > > fireDisplayEvents="true" />

> > > <TITLE>pgHelp</TITLE>

> > > </HEAD>

> > > <body BGCOLOR="white" bgcolor="#FFFFFF" text="#000000"

> > > link="#0000FF" vlink="#800080" alink="#FF0000">

> > > <jato:form name="pgHelp" method="post">

> > > </jato:form>

> > > <%@ include file="/IPP/ipp/pgFooter.jsp"%>

> > > </BODY>

> > > </HTML>

> > > </jato:useViewBean>

> > > --

> > > This is my pgFooter.jsp

> > >

> > > <jato:view name="IPP.ipp.pgFooterViewBean">

> > > <hr color=red size=2>

> > > from new_footer.jsp in IPP/ipp directory

> > > <font size="-2" face="Arial"><i>Send comments to <a

> > > href="mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134 048139046">supportdept@a...</a>">Any Company</a></i></font>

> > > <hr color=red size=2>

> > > <jato:hidden name="hdFooter" fireDisplayEvents="true" />

> > > </jato:view>

> > > --

> > > There is no compilation error in pgFooterViewBean and in

> > > pgHelpViewBean.

> > > How ever iam getting a runtime error,

> > >

> > > 500 Internal Server Error

> > > /ipp/servlet/IPP.ipp.ippServlet:

> > >

> > > javax.servlet.ServletException: Compilation error occured:

> > >

> > > allaire.jrun.scripting.DefaultCFE:

> > > Errors reported by compiler:C:/Program

> > > Files/Allaire/JRun/servers/default/ipp/WEB-

> > > INF/jsp/jrun__IPP__ipp__pgHelp2ejsp13.java:105:50:105:50: Syntax:

> ;

> > > expected instead of this token

> > > -

> > >

> > > What could be the reason for this error message?

> > > We tried the same thing with another approach, instead of using

> > > include directive, we directly copied the code of pgFooter.jsp in

> > > pghelp.jsp.

> > > even that is giving the same error..

> > >

> > > -

> > > <<a href="/group/SunONE-JATO/post?protectID=073229104237229198">%@p...</a> info="pgHelp" language="java"%>

> > > <<a href="/group/SunONE-JATO/post?protectID=073229114237229153036171">%@t...< /a> uri="/WEB-INF/jato.tld" prefix="jato"%>

> > > <jsp:useBean id="viewBean" class="IPP.ipp.pgHelpViewBean"

> > > scope="request"></jsp:useBean>

> > > <jato:useViewBean className="IPP.ipp.pgHelpViewBean">

> > > <HTML>

> > > <HEAD>

> > > <jato:textField name="tbUserID" size="20" maxLength="20"

> > > fireDisplayEvents="true" />

> > > <TITLE>pgHelp</TITLE>

> > > </HEAD>

> > > <body BGCOLOR="white" bgcolor="#FFFFFF" text="#000000"

> > > link="#0000FF" vlink="#800080" alink="#FF0000">

> > > <jato:form name="pgHelp" method="post">

> > > </jato:form>

> > >

> > > <jato:view name="IPP.ipp.pgFooterViewBean">

> > > <hr color=red size=2>

> > > from new_footer.jsp in IPP/ipp directory

> > > <font size="-2" face="Arial"><i>Send comments to <a

> > > href="mailto:<a href="/group/SunONE-JATO/post?protectID=061075104115193209050223163176249165134 048139046">supportdept@a...</a>">Any Company</a></i></font>

> > > <hr color=red size=2>

> > > <jato:hidden name="hdFooter" fireDisplayEvents="true" />

> > > </jato:view>

> > >

> > > </BODY>

> > > </HTML>

> > > </jato:useViewBean>

> > > --

> > > Please give us a feasible solution to solve this problem.

> > >

> > > Thx

> > > Ravi

> > >

> > >

> > > In <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166136 248038136183193071193172194143142">iPlanet-JATO@egroups.com</a>, "Todd Fast" <<a href="/group/SunONE-JATO/post?protectID=101233080150035167169232031248066208071 048">Todd.Fast@S...</a>>

> wrote:

> > > > Craig & Eric--

> > > >

> > > > (If you're not interested in the resolution to the problem Craig

> > > posted,

> > > > please skip ahead to the section in which I describe the

> preferred

> > > technique

> > > > for including headers and other common content in a JATO page.

> This

> > > > discussion is very important because I introduce the concept of

> > > "view

> > > > compostion", in which JATO pages are composed of modular and

> > > reusable view

> > > > components. This is one of the most powerful new features of

> JATO,

> > > and a

> > > > capability that simply wasn't possible in NetDynamics.)

> > > >

> > > > Posted Problem Resolution

> > > > -

> > > >

> > > > Craig & Eric, from what I can tell, you are both trying to

> include

> > > a full

> > > > view bean in a parent page at translation time. This is not

> > > possible, as

> > > > you can see from the compiler errors you get. There are

> collisions

> > > when

> > > > multiple top-level tags are included in the same JSP.

> > > >

> > > > When I said earlier that you needed to use a translation-time

> > > include

> > > > instead of a run-time include, I was assuming that you were

> trying

> > > to

> > > > include a fragment of HTML/JSP in the parent page. By

> fragment, I

> > > mean HTML

> > > > or JSP content that does not declare a view bean or form, but

> rather

> > > > references views contained within the parent view bean. If you

> > > want to

> > > > include a full page (JSP + ViewBean) in another page, then you'd

> > > need to use

> > > > a run-time include. A run-time include temporarily pauses the

> > > rendering of

> > > > the current page, and sends the full request to the included

> page

> > > as if it

> > > > were a separate client request. The resulting content from the

> > > included

> > > > page is inlined into the parent page's content, and processing

> of

> > > the parent

> > > > page then continues.

> > > >

> > > > Now I realize after thinking about it a bit that we may not have

> > > > sufficiently provided for full page includes because of some

> late-

> > > breaking

> > > > changes in the request context handling. After some basic

> testing,

> > > it

> > > > appears that if you try to include one JATO page in another by

> > > referencing

> > > > the JSP, the included page will cause a class cast exception to

> > > occur.

> > > > There may also be problems because the request context on the

> > > included page

> > > > will not have been set. In any case, full JATO page inclusion

> > > looks like

> > > > it's an issue we're going to have to address with some fixes

> before

> > > it will

> > > > work properly. My apologies. (One workaround if this is

> necessary

> > > is to

> > > > make the included view bean a child view of the parent view

> bean.

> > > I won't

> > > > go into that however).

> > > >

> > > > How to Include Common Content

> > > >

> > > >

> > > > Now, on to the discussion of the preferred way of including

> common

> > > content

> > > > in a JATO page. Let's say you have a common header you want to

> > > include in

> > > > one or more of your JATO pages. Because of the issue I noted

> > > above, and the

> > > > fact that the header is not really independently displayable,

> you

> > > don't want

> > > > to do a run-time include (which, remember, would necessitate

> > > including a

> > > > full JATO page).

> > > >

> > > > Instead, you should include the header as an HTML/JSP fragment

> > > using a

> > > > translation-time include. Depending on whether your header has

> > > dynamic

> > > > information, you can do one of two things. If the header is

> just

> > > static

> > > > content and/or set of links, you can just reference the HTML

> > > fragment in the

> > > > parent HTML directly, and you won't need any kind of view or

> view

> > > bean to

> > > > back it, or any reference to anything in JATO.

> > > >

> > > > If you need some dynamic info in the header, like the module URL

> > > for a link,

> > > > you can reference the parent page's view bean for this

> information

> > > by simply

> > > > including references to the parent page's implicit JSP variables

> > > (viewBean,

> > > > currentVIew, and currentTiledView). For example:

> > > >

> > > > Parent JSP:

> > > > -

> > > > <jsp:useBean id="viewBean" class="..."

> > > scope="request"></jsp:useBean>

> > > > <jato:useViewBean className="..." fireChildDisplayEvents="true">

> > > > ...

> > > > <%@ include file="MyInclude.jsp" %>

> > > > ...

> > > > </jato:useViewBean>

> > > > -

> > > >

> > > > Included content (MyInclude.jsp):

> > > > -

> > > > ... viewBean.getRequestContext().getModuleURL() ...

> > > > -

> > > >

> > > > The final HTML with the included content would then look like

> this:

> > > > -

> > > > <jsp:useBean id="viewBean" class="..."

> > > scope="request"></jsp:useBean>

> > > > <jato:useViewBean className="..." fireChildDisplayEvents="true">

> > > > ...

> > > > ... viewBean.getRequestContext().getModuleURL() ...

> > > > ...

> > > > </jato:useViewBean>

> > > > -

> > > >

> > > > MyInclude.jsp will be inlined in the parent JSP before it is

> > > translated to a

> > > > servlet. Note that it does not include the full HTML tags

> normally

> > > found in

> > > > an HTML file--there are no <html>, <head>, or <body> tags

> because

> > > it is not

> > > > expected to be used outside of an include page. In effect,

> this is

> > > the

> > > > equivalent of a server-side include (SSI).

> > > >

> > > > Now, if you need truly dynamic info in the header, like say you

> > > want to

> > > > display the user's name and SSN, then you'd likely want to

> embed a

> > > child

> > > > view in the parent view bean which will encapsulate & provide

> the

> > > necessary

> > > > information. This is in contrast to actually making these

> fields

> > > direct

> > > > children of the the parent view bean, which would be a tedious

> and

> > > error

> > > > prone task on every page you wanted to include this information.

> > > Let me try

> > > > to contrast these two approaches with a diagram of parent-child

> > > > relationships:

> > > >

> > > > Here's the bad way:

> > > >

> > > > ParentViewBean (ViewBean)

> > > > |

> > > > +-- UserFirstName (StaticTextField)

> > > > |

> > > > +-- UserSSN (StaticTextField)

> > > >

> > > > In this situation, you'd need to provide the logic to populate

> > > these fields

> > > > in every view bean on which they appeared. This is tedious and

> > > essentially

> > > > eliminates the "common"-ness of the content (this is also what

> > > NetDynamics

> > > > forced people to do).

> > > >

> > > > Now, the better way:

> > > >

> > > > ParentViewBean (ViewBean)

> > > > |

> > > > +-- MyHeaderView (MyHeaderView.java)

> > > > |

> > > > +-- UserFirstName (StaticTextField)

> > > > |

> > > > +-- UserSSN (StaticTextField)

> > > >

> > > > In the better way, you can see that the header information is

> > > encapsulated

> > > > in an instance of "MyHeaderView", which is a subclass of

> > > ContainerViewBase

> > > > or one of the other ContainerView subtypes. The population of

> the

> > > data

> > > > fields is encapsulated in that view, and the parent view need

> not

> > > know

> > > > anything about what's actually being displayed by that view.

> > > >

> > > > Thus, you can see that MyHeaderView, in conjunction with a

> snippet

> > > of JSP

> > > > content in a companion file, is completely modular and can be

> > > embedded in

> > > > any parent view bean on which you want the header to appear.

> The

> > > only

> > > > requirement is then to include MyHeaderView as a child view of

> the

> > > parent

> > > > view bean, and to include the correct JSP content that

> references

> > > that child

> > > > view.

> > > >

> > > > The included JSP content would now look something like this:

> > > > --

> > > > <jato:view name="MyHeaderView">

> > > > <table>

> > > > <tr><td>... <jato:staticText name="UserFirstName"/>

> ...</td></tr>

> > > > <tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>

> > > > </table>

> > > > </jato:view>

> > > > --

> > > >

> > > > If we now included this content in the parent JSP from further

> > > above, we get

> > > > the following as the JSP content before it is translated into a

> > > servlet:

> > > > -

> > > > <jsp:useBean id="viewBean" class="..."

> > > scope="request"></jsp:useBean>

> > > > <jato:useViewBean className="..." fireChildDisplayEvents="true">

> > > > ...

> > > > <jato:view name="MyHeaderView">

> > > > <table>

> > > > <tr><td>... <jato:staticText name="UserFirstName"/>

> ...</td></tr>

> > > > <tr><td>... <jato:staticText name="UserSSN"/> ...</td></tr>

> > > > </table>

> > > > </jato:view>

> > > > ...

> > > > </jato:useViewBean>

> > > > -

> > > >

> > > > Ultimately, this technique is called "view compostion" or "view

> > > > aggregation", and is one of the major new features of JATO. You

> > > can now

> > > > define reusable view components and embed them in multiple view

> > > containers,

> > > > on the same page or on different pages. Each page acts as a

> frame,

> > > in which

> > > > you provide the contents from modular components. Using this

> > > technique, you

> > > > can develop reusable view classes and chunks of JSP that can be

> > > arbitrarily

> > > > combined into complex pages.

> > > >

> > > > I know this is a long and rambling discussion, but I hope I've

> made

> > > myself

> > > > at least partly clear. I'm more than happy to clarify anything

> or

> > > elaborate

> > > > more. Please let me know.

> > > >

> > > > Todd

> > > >

> > > > --

> > > > Todd Fast

> > > > Senior Engineer

> > > > Sun/Netscape Alliance

> > > > <a href="/group/SunONE-JATO/post?protectID=189233080150035131169232031248130208071 048">todd.fast@e...</a>

> > >

> > >

> > > <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166215 146166214017110250006230056039126077176105140127082088124241215002153">iPlane t-JATO-unsubscribe@egroups.com</a>

> > >

> > >

> > >

> > >

>

>

> <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166215 146166214017110250006230056039126077176105140127082088124241215002153">iPlane t-JATO-unsubscribe@egroups.com</a>

>

>

>

Guest at 2007-7-1 16:35:55 > top of Java-index,Development Tools,Java Tools...