怎么用模板做网站,创意设计椅子,网站移动端指的是什么,弹窗广告最多的网站我将展示如何以编程方式“即时”将火车停靠站添加到ADF火车中。 在我的用例中#xff0c;我有一些票务预订应用程序。 它具有训练模型的有限任务流。 在火车的第一站#xff0c;用户输入乘客的数量#xff0c;在随后的站点#xff0c;他们输入一些乘客的信息。 带有乘客信息… 我将展示如何以编程方式“即时”将火车停靠站添加到ADF火车中。 在我的用例中我有一些票务预订应用程序。 它具有训练模型的有限任务流。 在火车的第一站用户输入乘客的数量在随后的站点他们输入一些乘客的信息。 带有乘客信息的站点数量必须根据在第一个火车站点提交的值进行动态更改。 因此描述的行为的结果应如下所示 有界任务流具有以下结构 StartView活动是一个页面片段我们在其中输入乘客人数而DynamicView活动提供了一个页面片段来输入乘客的信息。 目前我们只有一个活动来提供乘客的信息如果乘客人数大于一个我将添加其他活动。 在StartView页面片段的inputNumberSpinbox提交其值设置为某些PageFlowScope支持bean的passengersNumber财产和行动的提交按钮是同一个bean的方法 public class MainTrain {//Extra added train stopsprivate ListActivityId dynamicStops new ArrayListActivityId();//Value of inputNumberSpinboxprivate int passengersNumber 1;public String buttonPress(){//The number of extra added train stops is greater than neededif (passengersNumber dynamicStops.size())clearExtraStops();else //The number of extra added train stops is less than needed if (passengersNumber-1 dynamicStops.size()) addDynamicStops(); return null;} 因此通过按Submit按钮我们可以根据inputNumberSpinbox的值添加一些火车停靠点或清除额外的停靠点 。 我们将所有添加的动态停靠点保存在dynamicStops列表中。 让我们看一下clearExtraStops方法 private void clearExtraStops() {for (int i dynamicStops.size(); i passengersNumber; i--) {//Get ActivityId to be removedActivityId removeActivityId dynamicStops.get(i-1);//Get current train model and remove train stopTrainModel trainModel TrainUtils.findCurrentTrainModel();trainModel.getTrainStops().remove(removeActivityId);//Remove activity from task flow definitiongetTaskFlowDefinition().getActivities().remove(removeActivityId);dynamicStops.remove(i-1);} } 该方法删除了两件事火车模型中的火车停靠点和任务流定义中的活动。 addDynamicStops方法将变得更加有趣 private void addDynamicStops() { for (int i dynamicStops.size(); i passengersNumber - 1; i) {//Creating new ActivityIdActivityId activityId new ActivityId(getTaskFlowId(), new StringBuilder(DynamicView).append(i).toString()); //The main trick of the post.//We consider DynamicView activity as a base for new train stop and new activity//Get base activity (DynamicView) and its train stopActivity baseActivity getBaseDynamicActivity();TrainStopContainer stopContainer (TrainStopContainer)baseActivity.getMetadataObject();TrainStop baseTrainStop stopContainer.getTrainStop();//Create new Activity based on DynamicView but with new ActivityId ActivityImpl activityImpl new ActivityImpl(baseActivity, activityId); //Add created activity to the task flow definitiongetTaskFlowDefinition().getActivities().put(activityId, activityImpl);//Create new train stop based on the DynamicViews train stopTrainStopModel trainStopModel new TrainStopModel(new TrainStopImpl(baseTrainStop, i2), activityId);//Add created train stop to the train stop modelTrainModel trainModel TrainUtils.findCurrentTrainModel();trainModel.getTrainStops().put(activityId, trainStopModel); //Add created activity to our listdynamicStops.add(activityId); }
}private Activity getBaseDynamicActivity() {ActivityId baseActivityId new ActivityId(getTaskFlowId(), DynamicView); MetadataService metadataService MetadataService.getInstance();return metadataService.getActivity(baseActivityId);
}private TaskFlowDefinition getTaskFlowDefinition() {MetadataService metadataService MetadataService.getInstance();return metadataService.getTaskFlowDefinition(getTaskFlowId());
}private TaskFlowId getTaskFlowId() {ControllerContext controllerContext ControllerContext.getInstance(); ViewPortContext currentViewPortCtx controllerContext.getCurrentViewPort(); TaskFlowContext taskFlowCtx currentViewPortCtx.getTaskFlowContext(); return taskFlowCtx.getTaskFlowId();
} 因此本文的主要技巧是创建新的活动并基于DynamicView的现有活动来停止站点。 为了实现这个想法我创建了两个类 ActivityImpl和TrainStopImpl 。 这些类只不过是相应地实现Activity和TrainStop接口的代理类。 它们将接口实现委派给基本实例除了一些特定的方法例如用于ID和DisplayName的getter之外 public class TrainStopImpl implements TrainStop { //Base instance private TrainStop baseTrainStop;private int mpassNo;private static final String PASSANGER_FORM Passengers data: ;public TrainStopImpl(TrainStop trainStop, int passNo) {baseTrainStop trainStop; mpassNo passNo;}//Specific implementationpublic String getDisplayName() {return new StringBuilder(PASSANGER_FORM).append(mpassNo).toString();}public String getOutcome() {return baseTrainStop.getOutcome();}public String getSequential() {return baseTrainStop.getSequential();}...public class ActivityImpl implements Activity {private Activity baseActivity;private ActivityId mid;public ActivityImpl(Activity activity, ActivityId id) {baseActivity activity;mid id;}//Specific implementationpublic ActivityId getId() {return mid;}public String getType() {return baseActivity.getType();}public Object getMetadataObject() {return baseActivity.getMetadataObject();}
... 这篇文章的另一张图片只是为了展示它的工作原理 就这样 您可以下载JDeveloper 11.1.1.2.0的示例应用程序 。 参考 动态ADF列车。 通过ADF实践博客中的JCG合作伙伴 Eugene Fedorenko以编程方式添加火车停靠站 。 翻译自: https://www.javacodegeeks.com/2012/05/dynamic-adf-train-adding-train-stops.html