Thanks David and Ramsey. I seem to be having issues, unfortunately.
To clarify, originally, I was planning to have the admin component be a subcomponent within the normal wrapper (by "normal I mean pre-d2w -- not "non"-d2w as I previously suggested. I meant the site works without d2w, I just thought adding the admin as d2w would be a good way to learn d2w). Anyway, I attempted to accomplish this by making my Admin component essentially a copy of the PageWrapper from ERModernMoviesDemo . . . but got confused by the head and body stuff. Now I see that was likely the source of many of my issues.
So now I am trying to do exactly what you suggest and open a new window with a page level admin component via D2W. (restoring the html, head and body tags). Now, however, when ERD2WHead asks for this:
D2WContext context = (D2WContext) context().page().valueForKey("d2wContext");
I am getting null. I have the d2wContext method inside my Admin component (copied from the modern movies demo), and also have the body class method.
public D2WContext d2wContext() {
if (context().page() instanceof D2WPage) {
D2WPage d2wPage = (D2WPage) context().page();
return d2wPage.d2wContext();
}
return null;
}
public String bodyClass() {
String result = null;
String pageConfig = (String)d2wContext().valueForKey("pageConfiguration");
if (pageConfig != null && pageConfig.length() > 0) {
result = pageConfig + "Body";
}
return result;
}
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<webobject name = "HeadTag">
<webobject name = "StyleSheets" />
</webobject>
<webobject name = "BodyTag">
<webobject name = "IsDebug">
<div id="ERD2WDebugFlags"><webobject name = "ERD2WDebugFlags" /></div>
</webobject>
<div id = "ContentWrapper">
<div id = "MenuHeader">
<webobject name = "ERXNavigationMenu"/>
</div>
<div id = "MainContent">
<webobject name = "MainContent" />
</div>
</div>
<webobject name = "WOLToolBar"/>
<webobject name = "ERMD2WStyleSheetInjector"/>
</webobject>
</html>
wod:
ERXNavigationMenu : ERXNavigationMenu {
navigationContext = navigationContext;
}
MainContent : WOComponentContent {
_unroll = YES;
}
BodyTag : WOBody {
class = bodyClass;
}
HeadTag : ERD2WHead {
}
EntitiesMenu : MenuHeader {
}
ERD2WDebugFlags : ERD2WDebugFlags {
context = d2wContext;
}
IsDebug : WOConditional {
condition = application.isDevelopmentMode;
}
StyleSheets : ERMD2WCSSReference {
localContext = d2wContext;
}
WOLToolBar : WOLToolBar {
expanded = true;
}
ERMD2WStyleSheetInjector : ERMD2WStyleSheetInjector {
localContext = d2wContext;
}
I still have the rule in my rule file telling the pageWrapperName to be "Admin"
Still isn't loading. I assume there is something else I am missing. (Note I am for now, abandoning doing the subcomponent method.)
On Jun 9, 2010, at 3:32 PM, David Holt wrote:
Hi Andrew,
In order to minimize the work that you need to do, I would consider rethinking your approach to the admin side. Instead of it opening inside your AUC, why don't you have the admin link open up a nice full page completely outside your current pagewrapper with the unchanged ERModernLook all ready to go?
Your admin link will call something like session.navController.adminAction() (see the ModernMoviesDemo for examples), and you will include the PageWrapper and MenuHeader from the example in your application. Then the D2W rule system will find the pagewrapper, menuheader and skin framework required to make the complete page. Part of your navigation strategy on the Admin/D2W side will need to include a link back to reload the "normal" page wrapper.
Once you figure out how D2W ties all this together, it will be easier to figure out how to frame it within your original strategy.
If you want to go ahead with your current strategy see further notes below...
Also see David LeBer's responses in the thread from a few weeks ago which will give you some idea of the complexity involved in the opposite problem: "embedding standard components into ERModernDirectToWeb"
On 9-Jun-10, at 11:10 AM, Andrew R. Kinnie wrote:
Thanks. I added a rule in the d2wmodel file for pageWrapperName. However, I managed to discover several other problems.
The pagewrapper will need to include a call to the D2W context. Every ERModernLook page needs access to this.
My page wrapper was for a non-d2w page and site,
<aside>This is a common misconception. There's really no such thing as a non-D2W site. You can use as much or as little D2W as you wish. Your pages are either created by the D2W factory or they're not. Your web application either includes the D2W frameworks or it doesn't. Those are the distinctions, rather than "D2W App" or "non-D2W app".</aside>
and I want the d2w stuff to be a subcomponent of this. It is very simple, I have a header, sidebar navigation, and an AjaxUpdateContainer which changes based on what link the user clicks on the navigation sidebar. One of these links is the Admin link, which will (I hope) cause the D2W stuff to be loaded into the AjaxUpdateContainer, without disturbing anything else.
Your PageWrapper component will need to provide the D2WContext. If you plan to go with ERModernLook you're going to have to look carefully at the CSS. I am pretty sure that it also depends on the body class being in your PageWrapper.
I therefore made my Admin component into the "pageWrapperName" for the purposes of the D2W rule, and created it based on the pageWrapper from ERModernMoviesDemo.
Not sure what you mean here. Is the Admin component included inside the AUC or is it going to be a page level component?
1. I changed it to remove the header because this is a subcomponent. However, this removed the stylesheets tag. I also eliminated the bodyTag webobject, again, as this is a subcomponent. Neither of these seem to affect this problem though.
I think that D2W expects whatever component you use for the PageWrapper to contain the page level HTML. All the D2W page level components would depend on that. Otherwise what you might be looking for are the embeddable components (remember that there was a palette of these things in WOBuilder?).
This works, sort of, but the WOLToolbar appears as a ul above the ul of the entities. (I had an error here until I added the WOLips framework and password) I assume this is related to the navigation panel not being styled properly.
Yeah you're messing with the assumptions that were made in creating the CSS for ModernLook, I expect. The WOLToolbar is styled to be at the bottom of the page.
The real problem is that when I click an entity, now I get an NPE error:
ERMD2WStyleSheetInjector.java 39 resourceFrameworkName er.modern.directtoweb.components
Which apparently means it's not getting the skin framework (and also isn't supplying the default of "app") I added the property to the skin framework's properties file (then added it to the app's properties too to see if that changed anything. It didn't. I assume this is related to the missing stylesheets from the head.
This is established by the rules. You've messed with the framework's assumptions for the styling.
2. I then added the head and body back (along with the bodyClass method lifted from the ERModernMoviesDemo's pageWrapper). I changed it from an Ajax link to a regular WOHyperlink and set target = "new" but now I get an NPE like this (before I get to the uls from the WOLToolbar or the entitities) :
ERD2WHead.java 32 displayNameForPageConfiguration er.directtoweb.components
(Note this also happens inside the AjaxUpdateContainer if I keep it as an AjaxUpdateLink with the appropriate containerid)
You can't use the head and body tag nested inside a component that contains head and body tags (which I am assuming your Main component does)