关于task flow和object scope

本文探讨了在设计页面时如何合理选择ManagedBean的作用域。建议避免使用应用级和会话级作用域,以确保任务流的封装性和可重用性。推荐使用页面流作用域来传递数据值,在当前视图活动中使用视图作用域,并仅在当前请求中使用请求作用域。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我们在设计开发一个新的页面的时候,managed bean选择何种scope更适合业务逻辑?何种scope下managed bean中的变量会随着页面一起刷新?希望下面的这段话能给你点启示。

When determining what scope to use for variables within a task flow, you should use any of the scope options other than application or session scope. These two scopes will persist objects in memory beyond the life of the task flow and therefore compromise the encapsulation and reusable aspects of a task flow. In addition, application and session scopes may keep objects in memory longer than needed, causing unneeded overhead.

When you need to pass data values between activities within a task flow, you should use page flow scope. View scope is recommended for variables that are needed only within the current view activity, not across view activities. Request scope should be used when the scope does not need to persist longer than the current request. It is the only scope that should be used to store UI component information. Lastly, backing bean scope must be used for backing beans in your task flow if there is a possibility that your task flow will appear in two region components or declarative components on the same page and you would like to achieve region instance isolations.


<?xml version="1.0" encoding="UTF-8"?> <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="diagram_Process_1753060676983" targetNamespace="http://bpmn.io/schema/bpmn" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="Process_1753060676983" name="业务流程_1753060676983" isExecutable="true"> <bpmn2:startEvent id="Event_1boh5k6" name="开始" camunda:formKey="key_1938481912687386626"> <bpmn2:outgoing>Flow_0h85tm0</bpmn2:outgoing> </bpmn2:startEvent> <bpmn2:sequenceFlow id="Flow_0h85tm0" sourceRef="Event_1boh5k6" targetRef="Activity_0uavnj8" /> <bpmn2:endEvent id="Event_01gmk4w" name="结束"> <bpmn2:incoming>Flow_0q7iqv6</bpmn2:incoming> </bpmn2:endEvent> <bpmn2:serviceTask id="Activity_1h8pm2l" name="扩展方法1" camunda:type="external" camunda:topic="aaa"> <bpmn2:incoming>Flow_1gm8ysv</bpmn2:incoming> <bpmn2:outgoing>Flow_11vpif7</bpmn2:outgoing> </bpmn2:serviceTask> <bpmn2:sequenceFlow id="Flow_11vpif7" sourceRef="Activity_1h8pm2l" targetRef="Activity_02oey02" /> <bpmn2:userTask id="Activity_02oey02" name="管理确定" camunda:candidateGroups="ROLE1"> <bpmn2:incoming>Flow_11vpif7</bpmn2:incoming> <bpmn2:outgoing>Flow_0q7iqv6</bpmn2:outgoing> </bpmn2:userTask> <bpmn2:sequenceFlow id="Flow_0q7iqv6" sourceRef="Activity_02oey02" targetRef="Event_01gmk4w" /> <bpmn2:userTask id="Activity_0uavnj8" name="人事审批" camunda:candidateGroups="ROLE1"> <bpmn2:incoming>Flow_0h85tm0</bpmn2:incoming> <bpmn2:outgoing>Flow_1gm8ysv</bpmn2:outgoing> </bpmn2:userTask> <bpmn2:sequenceFlow id="Flow_1gm8ysv" sourceRef="Activity_0uavnj8" targetRef="Activity_1h8pm2l" /> </bpmn2:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1753060676983"> <bpmndi:BPMNEdge id="Flow_1gm8ysv_di" bpmnElement="Flow_1gm8ysv"> <di:waypoint x="420" y="170" /> <di:waypoint x="520" y="170" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0q7iqv6_di" bpmnElement="Flow_0q7iqv6"> <di:waypoint x="790" y="170" /> <di:waypoint x="882" y="170" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_11vpif7_di" bpmnElement="Flow_11vpif7"> <di:waypoint x="620" y="170" /> <di:waypoint x="690" y="170" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0h85tm0_di" bpmnElement="Flow_0h85tm0"> <di:waypoint x="248" y="170" /> <di:waypoint x="320" y="170" /> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="Event_1boh5k6_di" bpmnElement="Event_1boh5k6"> <dc:Bounds x="212" y="152" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="219" y="195" width="23" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Event_01gmk4w_di" bpmnElement="Event_01gmk4w"> <dc:Bounds x="882" y="152" width="36" height="36" /> <bpmndi:BPMNLabel> <dc:Bounds x="889" y="195" width="23" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_1bu98ab_di" bpmnElement="Activity_1h8pm2l"> <dc:Bounds x="520" y="130" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_02oey02_di" bpmnElement="Activity_02oey02"> <dc:Bounds x="690" y="130" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_0uavnj8_di" bpmnElement="Activity_0uavnj8"> <dc:Bounds x="320" y="130" width="100" height="80" /> </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> 使用这个xml给我做一个案例,分两个项目,一个项目是camunda工作流的项目,一个是监听扩展方法的项目,我需要一个java的完整案例
最新发布
07-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值