2014-06-16 2 views
0

이전 작업에서 문자열 배열 집합을 기반으로 select 목록을 출력하는 렌더러를 작성하려고합니다.속성 렌더러에서 프로세스 변수에 액세스

List<String> names = new ArrayList<String>(); 
names.add("Bob"); 
names.add("Fred"); 

delegate.setVariable("names", names); 

내가 다음 EnumFormPropertyRenderer을 확장하려고 해요, 그리고 최우선 getPropertyField : 이전 작업의 execute 방법은 내가 가진

@Override 
public Field getPropertyField(FormProperty formProperty) { 

    ComboBox comboBox = new ComboBox(getPropertyLabel(formProperty)); 

    // Bits copied from getPropertyField in EnumFormPropertyRenderer   

    if (values != null) { 
     ... 

내 문제는 내가 액세스를 얻는 방법을 찾을 수 있다는 것입니다 내 배열 names 내에서 getPropertyField - 볼 수있는 formProperty의 일부가 아니며 실행 ID (get 변수에 대한 호출의 필수 매개 변수)에 대한 액세스 권한이없는 것으로 보이기 때문에 ProcessEngines.getDefaultProcessEngine().getRuntimeService() 내에서 볼 수 없습니다. .

그래서 getPropertyField 내에서 배열 names을 어떻게 얻을 수 있습니까? 아니면 처음부터 잘못된 각도에서 문제를 접근하고 있습니까?

답변

0

"이상적인"솔루션인지 확실하지 않지만 나를 위해 일한 것은 인스턴스 ID를 사용하는 것이 었습니다. 이 과정에서

@Override 
    public void execute(DelegateExecution delegate) throws Exception { 

     delegate.setVariable("instanceId", delegate.getProcessInstanceId()); 

    } 

, 내 작업은 이전과 배열을 설정, 현재의 위임에 대해 변수를 설정 :

List<String> names = new ArrayList<String>(); 
    names.add("Bob"); 
    names.add("Fred"); 

    delegate.setVariable("names", names); 
과정의 시작에서, 나는 다음과 같은 포함하는 서비스 작업을 추가 내 드롭 다운에이를 표시해야 할 때

그런 다음, 나는 변수 instanceId에 바인딩 :

<activiti:formProperty id="instanceId" 
     name="Please select the name" type="customSelection" 
     variable="instanceId" /> 

이이 건물의 렌더러에서 내가 retriev 수 있음을 의미 와 전자 인스턴스 ID : 다시 드롭으로 채우는

ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); 
    RuntimeService runtimeService = processEngine.getRuntimeService(); 
    List<String> names = (List<String>) runtimeService.getVariable 
     (currentInstanceId, "names"); 

:

String currentInstanceId = (String) formProperty.getValue(); 

그리고 마지막으로는 내 배열을 검색합니다.

유일한 문제는 내 경우에 문제가되지 않았던 변수 instanceId에 다시 채워지는 것이지만 다른 곳에서는있을 수 있습니다. 동일한 드롭 다운이 다시 필요하면 instanceId을 재설정하기 위해 첫 번째 서비스 작업에 또 다른 호출이 필요합니다.