users@javaserverfaces-spec-public.java.net

[jsr344-experts mirror] Re: New stereotype for _at_Named and @FlowScoped

From: Edward Burns <edward.burns_at_oracle.com>
Date: Thu, 31 Jan 2013 15:09:34 -0800

>>>>> On Thu, 31 Jan 2013 17:05:57 +0100, Arun Gupta <arun.p.gupta_at_oracle.com> said:

AG> Building applications that use Faces Flow, I expect
AG> @Named
AG> @FlowScoped

AG> to be used commonly on flow-scoped beans.

AG> Can a new stereotype be defined to accommodate this design pattern ?

Hello Arun,

After consultation with the CDI spec lead, it seems a better way is to
use a producer method. With this approach, you simply have to have a
method that is tagged with

@Produces @FlowDefinition which has a FlowBuilder parameter that is
tagged with @FlowBuilderParameter. For example

public class FlowA implements Serializable {
    
    private static final long serialVersionUID = -7623501087369765218L;

    public FlowA() {
    }
    
    @Produces @FlowDefinition
    public Flow buildMyFlow(@FlowBuilderParameter FlowBuilder flowBuilder) {
        String flowId = "flow-a";
        flowBuilder.id("", flowId);
        flowBuilder.viewNode(flowId, "/" + flowId + "/" + flowId + ".xhtml").markAsStartNode();
        flowBuilder.returnNode("taskFlowReturn1").
                fromOutcome("#{flow_a_Bean.returnValue}");
        flowBuilder.inboundParameter("param1FromFlowB", "#{flowScope.param1Value}");
        flowBuilder.inboundParameter("param2FromFlowB", "#{flowScope.param2Value}");
        flowBuilder.flowCallNode("callB").flowReference("", "flow-b").
                outboundParameter("param1FromFlowA", "param1Value").
                outboundParameter("param2FromFlowA", "param2Value");
        
        return flowBuilder.getFlow();
    }
}

I don't know if a stereotype can do this. I don't think it can.

Ed

-- 
| edward.burns_at_oracle.com | office: +1 407 458 0017
| homepage:               | http://ridingthecrest.com/