Re: How to initialize a self-instantiated Element, so that processTemplate can be called?

by Geert Bevin :: Rate this Message:

Reply to Author | View in Thread


Hi,

what happens is indeed that RIFE can only generate exit values when  
the web application is actually being used. There's some requite data  
which is only available when a request object is available. So, you  
need to make that request somehow. I think that for this, RIFE's out-
of-container testing could allow you to do what you want: http://rifers.org/wiki/display/RIFE/Out+of+container+testing

Retrieve your existing site instance and perform a request on the  
element that would normally print out that template. Then you have  
several options, either the output is exactly what you want, and you  
can use response.getText(). Another option is to use  
response.getTemplate(), and only use parts of your template structure.

Hope this helps,

Geert

On 04 Jul 2008, at 17:53, kodde wrote:

>
> Hi folks,
>
> I really enjoy using RIFE for my small project here, but currently I
> am stuck at a problem with Element objects and their not yet
> initialized contexts. I will try to explain my problem in detail:
>
> I have written an Executor class called "RequestUpdater" which gets
> executed every minute. I want this RequestUpdate to send an email on
> each execution, which basically works fine by now.
> Because I really like the templating system provided by Rife, I wanted
> to create the mail body via templates. Usually this would be no
> problem, because I could simply extend the Element class, select a
> template and call the "processTemplate" method. Now here comes the
> problem:
>
> Within my RequestUpdater (extending Executor) there is no
> processTemplate or anything approrpiate (of course not). So I tried to
> instantiate an existing class extending the Element class and called
> the processTemplate from there. Unfortunately I only get the
> Exception:
>
> "This element executed a method that requires a fully initialized
> element context"
>
> which I basically understand, but I don't know how to initialize the
> context of the element on my own. I tried something like
> Site.getRepInstance().resolveId("myId").getImplementationBlueprint but
> this doesn't work either (it's always null).
>
> So is there any possibility to use the template mechanism from within
> an Executor or do I have to hard code the output instead of using
> setOutput and EXIT:QUERY methods??
>
> Thanks in advance for your suggestions, and please excuse my bad
> English, it's not my mother tongue ;)
> >

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price!
 
 
 
Google
rifers.org web