Re: Binding component output to a string

Ian Baxter <[email protected]>
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Before anyone responds, here's an update.
I've taken a different approach -- Rather than generate the output  
and bind it to a WOString, I am generating the HTML template and WOD  
on the fly, and overriding the template() method on WOComponent. Now  
I just have to figure out a good caching scheme...

Ian

On Sep 7, 2006, at 10:58 AM, Ian Baxter wrote:

> Hi,
>
> I'm trying to programmatically generate the HTML output for a  
> reusable WOComponent and bind that output to a WOString. I've found  
> a way to do this, however, when an action is invoked from the  
> component who's content was generated (the component contains a  
> form) I get the following exception:
>
> <WorkerThread0> java.lang.NullPointerException
> 	at com.webobjects.appserver._private.WOForm._enterFormInContext 
> (WOForm.java:58)
> 	at com.webobjects.appserver._private.WOForm.invokeAction 
> (WOForm.java:79)
> 	at com.webobjects.appserver.WOComponent.invokeAction 
> (WOComponent.java:945)
> 	at com.webobjects.appserver.WOSession.invokeAction(WOSession.java: 
> 1168)
> 	at com.webobjects.appserver.WOApplication.invokeAction 
> (WOApplication.java:1375)
> 	at  
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchW 
> ithPreparedPage(WOComponentRequestHandler.java:196)
> 	at  
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchW 
> ithPreparedSession(WOComponentRequestHandler.java:287)
> 	at  
> com.webobjects.appserver._private.WOComponentRequestHandler._dispatchW 
> ithPreparedApplication(WOComponentRequestHandler.java:322)
> 	at  
> com.webobjects.appserver._private.WOComponentRequestHandler._handleReq 
> uest(WOComponentRequestHandler.java:358)
> 	at  
> com.webobjects.appserver._private.WOComponentRequestHandler.handleRequ 
> est(WOComponentRequestHandler.java:432)
> 	at com.webobjects.appserver.WOApplication.dispatchRequest 
> (WOApplication.java:1306)
> 	at com.webobjects.appserver._private.WOWorkerThread.runOnce 
> (WOWorkerThread.java:173)
> 	at com.webobjects.appserver._private.WOWorkerThread.run 
> (WOWorkerThread.java:254)
> 	at java.lang.Thread.run(Thread.java:613)
>
> Here is the code I'm using to generate the HTML string I'm binding  
> to the WOString in the parent component:
>
> public String generateOutput() { // This is bound to a WOString in  
> the parent component, thus displaying the component "MyComponent".
> 	MyComponent myComponent = (MyComponent)pageWithName("MyComponent");
>
> 	myComponent.takeValueForKey(displayGroup, "displayGroup");
> 	myComponent.takeValueForKey(product, "product");
> 		
> 	WOResponse response = myComponent.generateResponse();
> 		
> 	return response.contentString();
> }
>
> MyComponent contains a form with a few buttons that perform actions  
> on the bound WODisplayGroup.
>
> You're probably wondering why do I need to do this... The short  
> answer is that I'm using a template engine, and I need to give  
> users a way to place the output of components in their templates.
>
> Any help would be much appreciated.
>
> Thanks,
>
> Ian Baxter
> _______________________________________________
> WebObjects-dev mailing list
> [email protected]
> http://www.omnigroup.com/mailman/listinfo/webobjects-dev

_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.