Need your suggestion on this,
damar thapa <[email protected]>
| Newsgroups | gmane.comp.java.enhydra.barracuda.general |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have shown the snapshot of my MyPage.html, Header.html, and MyPageModel class of MyPage.java following this message. MyPage.java basically
combines Header.html, Footer.html, and other html files into MyPage.html, and is working fine.
To add a new page of similar kind, say Page1, I copied MyPage.java to Page1.java and MyPage.html to Page1.html. In Page1.java,class name changed
to Page1(and other relevant changes),and in Page1.html, all "Dir::Get_Data.MyPage.???" became "Dir::Get_Data.Page1.???" (id became "Page1" etc).
But,I have a problem with Header.html's "Dir::Get_Data.MyPage.Link1" (a BLink). To make it work for Page1, I have to
change it to "Dir::Get_Data.Page1.Link1", I guess,which means I may have to have separate Header.html file for each new pages
(not good approach, since Header.html is supposed to be for sharing).
How can solve this problem,or am not to use Blink, but directly use <a href="somedomain.com/~link1" in Header.html file?
Or can I do something in Page1.java within "if(key.equals("Link1")" to make it work?
Any pointers would be highly appreciated.
Damar
======Start of MyPage.html======
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html id="MyPage">
<head>
<title></title>
</head>
<body>
<table>
<tr>
<td>
<table width="750">
<tr>
<td class="Dir::Get_Data.MyPage.Header">[Header]</td>
</tr>
<tr>
<td class="Dir::Get_Data.MyPage.Footer">[Footer]</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
====Start of Header.html=====
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html id="MyPage">
<head>
<meta name="GENERATOR" content="IBM WebSphere Homepage Builder V4.0.0 for Linux">
<title></title>
</head>
<body>
<table id="header" width="100%" cellspacing="1" bgcolor="#000000" cellpadding="1">
<tr>
<td nowrap valign="middle" align="center" bgcolor="#ff0000">
<a class="Dir::Get_Data.MyPage.Link1" href="Sarine">
<img src="graphics/toLink1.jpg"
width="90" height="27" border="0"></a>
</td>
</tr>
</table>
</body>
</html>
=====start of MyPage.java ============
class MyPageModel extends AbstractTemplateModel {
//register the model by name
public String getName() {
return "MyPage";
}
//provide items by key
public Object getItem(String key) {
ViewContext vc = getViewContext();
if (key.equals("Title")) return "MyPage Title";
else if (key.equals("Header")){
XMLObject header =
xmlcFactory.create(mypage.presentation.HeaderHTML.class);
Node headerNode = header.getElementById("header");
return vc.getElementFactory().getDocument().importNode(headerNode, true);
}
else if (key.equals("Footer")) {
XMLObject footer =
xmlcFactory.create(mypage.presentation.FooterHTML.class);
Node footerNode = footer.getElementById("footer");
return vc.getElementFactory().getDocument().importNode(footerNode, true);
}
else if(key.equals("Link1")){
BLink blink1 = new
BLink("","http://somedomain.com/~link1", vc);
return blink1;
}
else return super.getItem(key);
}
}
}