Inserting a new sub-component (programmatically) in appendToResponse()
Inserting a new sub-component (programmatically) in appendToResponse()
- Subject: Inserting a new sub-component (programmatically) in appendToResponse()
- From: Mark Gowdy <email@hidden>
- Date: Mon, 08 Jun 2009 13:58:06 +0100
Hello,
I need to insert a new sub-component into a page during the request-response cycle (probably within appendToResponse() )
I thought I had achieved this, but all the links on the page are now broken (and other general weirdness unfolds)
This is the essence what I need to achieve (I removed all the specific crud that you don't need)
This breaks: public void appendToResponse(WOResponse a_rsp, WOContext a_ctx) { super.appendToResponse(a_rsp, a_ctx);
// Prepare a sub-component (then pass it bindings, etc..)
// DisplayArticle generatedContent = ((ERXApplication)ERXApplication.application()).pageWithName(DisplayArticle.class, a_ctx); // the other way
DisplayArticle newComponent = (DisplayArticle)pageWithName("DisplayArticle"); String generatedContentForCMSTag = newComponent.generateResponse().contentString(); // Do stuff // Update a_rsp.setContent(adjustedContent);
}
I need this to not break.
I suspect that this is messing up the object graph that it uses when invokeAction and takeValuesFromRequest is called. Do I need to register (or unregister) these components somehow after they are created. The DisplayArticle component ONLY ever use direct actions, so I will not be using normal actions within these. They do however need to retain their session info.
--
This might look a little bit mad (when out of context), so if you are interested, this is why I want to do it: I am parsing 'a_rsp.contentString();' using a regex so that I can locate tags that may appear (these tags may have come from a string (from a content managed article in the database) These are in the form: <cms:DisplayTitle displayTitle = "About Us" linkToArticle = "Y" artTitle = "About Us" /> The plan is to find these, and replace them with a generated component (into which I pass those bindings)
The cool thing is, that the inserted article can also contain one of these tags, hence we have a simple content management structure.
If there is a better way to do this, feel free to enlighten me.
Thanks in advance,
Mark
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden