Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple Variable in Web Flow

I've different view-state's in flow.xml. All of theses states have the same view. Now i want to set a variable which includes just a String und call it in the view-file to customize the content.
Here are my files:
flow.xml: for the example two of the view-state's

<view-state id="rcpm" view="rc/rcmembers.xhtml">
    <on-entry>
        <evaluate expression="RCHtmlCache.getCommunityList('rcpm')"
            result="flowScope.members" />
    </on-entry>
</view-state>

<view-state id="rcarch" view="rc/rcmembers.xhtml">
   <on-entry>
        <evaluate expression="RCHtmlCache.getCommunityList('rcarch')"
            result="flowScope.members" />
    </on-entry>
</view-state>

In this file i need a variable with the value of the view-state ID, so e.g "rcarch".

rcmembers.xhtml just the part of the code where i want to call the variable

<p:panel id="panel" header="Memberslist of **Here comes the value of the variable">

Hope you understand my problem...

like image 651
Michael Schmidt Avatar asked Mar 07 '13 09:03

Michael Schmidt


1 Answers

You have two options:

First, you can define it at flow definition level and expose it to the view directly:

<on-entry>
   <set name="flowScope.myView" value="flowRequestContext.currentState.id"/>
</on-entry>

Or you could pass the flow context to the controller and then expose it there:

<evaluate expression="RCHtmlCache.getCommunityList(flowRequestContext)" result="flowScope.members"/>

On the controller:

public String getCommunityList(RequestContext context) {
   context.getFlowScope().put("myView", context.getCurrentState().getId());
   ...
}

Hope that helps

like image 122
xpadro Avatar answered Oct 12 '22 13:10

xpadro