You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Stephan Frai <fa...@online.de> on 2008/03/19 09:55:23 UTC

AW: AW: AW: Orchestra beginner question: conversation.flash behaves like request scope - Different solution

Hi,	

injecting as prototype did not work. I don`t know why, and I did not
investigate.

I found a different solution, because I did not want to use the
viewController, because when using @viewController I had the names of views
in my Java files.

So I decided to declare the multi-time used beans serval times in spring.
For each workflow the needed bean is declared once:

<bean id="timeChainJSF" class="com.playoli.timeperiod.jsf.TimeChainJSF"
scope="conversation.access"
	orchestra:conversationName="regUserDirectPlanning">
		
	<property name="beanFactory" ref="timePeriodBeanFactory" />
	...
</bean>
	
<bean id="ru_edit_timeChainJSF"
class="com.playoli.timeperiod.jsf.TimeChainJSF"
	scope="conversation.access"
	orchestra:conversationName="regUserReservationEditing">
		
	<property name="beanFactory" ref="timePeriodBeanFactory" />
	...
</bean>

The id got a prefix for the workflow.

The workflow controller now look like that:

<bean id="reservationEditingJSF"
class="com.playoli.ruplanning.jsf.ReservationEditingJSF"
scope="conversation.access" 
      orchestra:conversationName="regUserReservationEditing"> 
	...
	<property name="chainData" ref="ru_edit_timeChainJSF"/>
	...
</bean>

<bean id="regUserDirectPlanningController"
class="com.playoli.ruplanning.jsf.RegUserDirectPlanningController"
	scope="conversation.access" 
	orchestra:conversationName="regUserDirectPlanning">
	...
	<property name="chainData" ref="timeChainJSF"/>
	...
</bean>

Each workflow has its own xhtml-Pages that include several jsp pages.
The jsp pages formerly referenced the jsf beans like "timeChainJSF".
These beans hold only values and do no persistence.

Now I use Facelets ui:param to inject the right timeChain-bean into the jsp
page:

DirectPlanning.xhtml:

<ui:include  src="/WEB-INF/pages/timeperiod/timeChainOverview.jsp">
  <ui:param name="reservationConfirmation"
value="#{regUserDirectPlanningController.chainData}"/>
</ui:include>

EditPlanning.xhtml:
<ui:include  src="/WEB-INF/pages/timeperiod/timeChainOverview.jsp">
  <ui:param name="reservationConfirmation"
value="#{reservationEditingJSF.chainData}"/>
</ui:include>

Exerpt of timeChainOverview.jsp:

...
<h:outputText
value="#{timeChainmessages['timechain_chain_daily_every_day']}"
rendered="#{reservationConfirmation.workDayOnly=='false'}"/>
...

Using this approach I am able to use the same jsps in different worklows,
while the jsps reference the correctly scoped beans of my workflow.


Regards,

Stephan


-----Ursprüngliche Nachricht-----
Von: Mario Ivankovits [mailto:mario@ops.co.at] 
Gesendet: Dienstag, 18. März 2008 14:28
An: MyFaces Discussion
Betreff: Re: AW: AW: Orchestra beginner question: conversation.flash behaves
like request scope

Mario Ivankovits schrieb:
> Are you using persistence from within the timeChainJSF bean?
> If not, you can inject the bean into your controller bean and use it
> through your controller.
> This is the solution I'd prefer.
>   
Should elaborate a little bit more about what I meant here.

If possible, use the TimeChainJSF bean as prototype and inject that into
your controller bean which has a conversation scope.

That way, each controller bean will get its own TimeChainJSF bean which
you'll be able to access through the controller than.

Hope that makes it a little bit clearer.

Ciao,
Mario