[Logo] RSF Discussions Forum
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
How to achieve this: 1 template, 2 producers ...  XML
Forum Index -> RSF Help and Problems
Author Message
TocydLive
Request-scope Wrangler

Joined: 18/06/2007 15:26:03
Messages: 121
Offline

Hi,

I'm trying to implement a generic template that will be used by two different producers (2 class that extends the same producer).

But as the two producers have the same VIEW_ID, that lead me to an error when I'm trying to invoke one of those producers. And this seem's to be normal as RSF use the VIEW_ID attribute to identify the template to use...

Can I do something to specify different VIEW_ID for those producers, then when one of those producers is invoke, just force the producer to use a specific template ?

Here is what I've done until now (not working as the producer use the same VIEW_ID):



Visual representation:
Code:
                      GenericProducerExtend1          GenericProducerExtend2
                        extend1Section1Renderer         extend2Section1Renderer
                                                        extend2Section2Renderer
                                      ^                                   ^
                                      |                                   |
                                      -------------------------------------
                                                             |
 
                                                    GenericProducer 
                     template.html <---------------------VIEW_ID = 'template'
                                                         section1Renderer
                                                         section2Renderer
                                                         ...
 


requestContext.xml
Code:
 <bean id="genericProducer" class="org.sakaiproject.atool.tool.producers.GenericProducer"
 abstract="true">
         <property name="appLogic" ref="appLogic" />
 </bean>
 
 <bean id="genericProducerExtend1" class="org.sakaiproject.atool.tool.producers.GenericProducerExtend1"
 parent="genericProducer">
         <property name="appLogic" ref="appLogic" />
         <property name="extend1Section1Renderer " ref="extend1Section1Renderer " />
 </bean>
 
 <bean id="genericProducerExtend2" class="org.sakaiproject.atool.tool.producers.GenericProducerExtend2"
 parent="genericProducer">
         <property name="appLogic" ref="appLogic" />
         <property name="extend2Section1Renderer " ref="extend2Section1Renderer " />
         <property name="extend2Section2Renderer " ref="extend2Section2Renderer " />
 </bean>
 
 <bean id="extend1Section1Renderer" class="org.sakaiproject.atool.tool.renderers.extend1Section1Renderer">
         ...
 </bean>
 
 <bean id="extend2Section1Renderer" class="org.sakaiproject.atool.tool.renderers.extend1Section1Renderer">
         ...
 </bean>
 
 <bean id="extend2Section2Renderer" class="org.sakaiproject.atool.tool.renderers.extend1Section1Renderer">
         ...
 </bean>
 



Thank's again for your help,

Simon Rousseau
CSSMI[img]

Simon Rousseau
[MSN]
antranig
Request-scope Wrangler

Joined: 03/04/2006 13:29:55
Messages: 643
Offline

What I suggest you do is move the information that you require to "switch" on out of the viewID into some other part of the ViewParameters state. Then you can inject two or more producers into the "head" producer that has the common VIEW_ID and then make a decision based on this other part of the ViewParameters, which of the producers to defer to for fillComponents.

http://ponder.org.uk/rsf/posts/list/130.page

If you absolutely require to vary the URL part in which the viewID appears for the different producers, you can write a ViewParamsInterceptor which accepts urls for a "fake" extra viewID that has no template for it, and adjusts the ViewParameters state so that it shifts this information into the "other part" that you set up for the above solution.

Hope this helps,
A.
TocydLive
Request-scope Wrangler

Joined: 18/06/2007 15:26:03
Messages: 121
Offline

Thank you for those suggestions!

I'm actually trying to use the ViewParamsInterceptor method...
But the custom ViewParamsInterceptor I've made is never fired up when I try to access a producer. Also, I've got an error that state that no template could be found for the fake view_id I've associated to the two producers that I'm trying to associate to the same template...

Here is what I've done until now:

applicationContext.xml:
Code:
 	<bean id="DevelopmentAgreementViewParamInterceptor"
 		  class="org.sakaiproject.portfolioprofessionneluseragreementcompetence.tool.interceptors.DevelopmentAgreementViewParamInterceptor">
 	</bean>
 


DevelopmentAgreementViewParamInterceptor.java
Code:
 public class DevelopmentAgreementViewParamInterceptor implements ViewParamsInterceptor {
 
 	public AnyViewParameters adjustViewParameters(ViewParameters incoming) {
 
 		if(incoming.viewID == "SearchAndDoActionProposal" || incoming.viewID == "SearchAndDoActionPeriod"){
 			incoming.viewID = "SearchAndDoAction";
 		}
 
 		return incoming;
 	}
 }
 


I don't know if its the way to achieve this, but at this time that doesn't work...

Cheer's,

Simon Rousseau
CSSMI

Simon Rousseau
[MSN]
antranig
Request-scope Wrangler

Joined: 03/04/2006 13:29:55
Messages: 643
Offline

The bean which is of the ViewParamsInterceptor type needs to be registered separately with Spring using the "viewParamsInterceptorParent" bean parent class -

Here is a "full" example, you needn't make a definition this complex if your interceptor is at application scope

http://ponder.org.uk/rsf/posts/list/158.page
 
Forum Index -> RSF Help and Problems
Message Quick Reply
Go to:   
Powered by JForum 2.1.6 © JForum Team