단추가 있는 표시줄을 표시하려면 Business Process Choreographer 탐색기 CommandBar 구성요소를 사용하십시오. 이 단추는 목록에서 선택한 오브젝트 또는 오브젝트의 자세히 보기에서 조작되는 명령을 나타냅니다.
<h:form> 태그에 bpe:commandbar 태그를 추가하십시오. bpe:commandbar 태그는 모델 속성을 포함해야 합니다.
다음 예는 타스크 인스턴스의 일부 등록 정보를 표시하기 위해 CommandBar 구성요소를 추가하는 방법을 보여줍니다.
<h:form> <bpe:commandbar model="#{TaskInstanceList}"> <bpe:command commandID="Refresh" > action="#{TaskInstanceList.refreshList}" label="Refresh"/> <bpe:command commandID="MyClaimCommand" > label="Claim" > commandClass="<customcode>"/> </bpe:commandbar> </h:form>
이 model 속성은 관리 Bean을 나타냅니다. 이 Bean은 ItemProvider 인터페이스를 구현해야 하며 선택된 Java™ 오브젝트를 제공합니다. CommandBar 구성요소는 일반적으로 동일한 JSP 파일에 있는 세부사항 구성요소 또는 목록 구성요소와 함께 사용됩니다. 일반적으로 이 태그에 지정된 모델은 동일한 페이지의 세부사항 구성요소 또는 목록 구성요소에 지정된 모델과 동일합니다. 예를 들어 목록 구성요소의 경우, 명령은 목록에서 선택한 항목에 대해 수행됩니다.
이 예에서 model 속성은 TaskInstanceList 관리 Bean을 나타냅니다. 이 Bean은 Java 오브젝트의 등록 정보를 제공하며 ItemProvider 인터페이스를 구현해야 합니다. 이 인터페이스는 BPCListHandler 클래스 및 BPCDetailsHandler 클래스에 의해 구현됩니다. 또한 사용자 정의 청구 명령을 포함합니다.
CommandBar 모델 속성이 이미 구성된 관리 Bean(예를 들어 목록 또는 세부사항 핸들러)을 나타낼 경우 추가 구성은 필요하지 않습니다. 이들 핸들러 중 하나의 구성을 변경했거나 다른 관리 Bean을 사용한 경우, ItemProvider 인터페이스를 구현하는 관리 Bean을 JSF 구성 파일에 추가하십시오.
다음 코드 스니펫은 명령 표시줄을 확장하는 명령 클래스를 작성하는 방법을 보여줍니다. 이 명령 클래스(MyClaimCommand)는 JSP 파일에 있는 bpe:command 태그에 의해 참조됩니다.
이 명령은 해당 전제조건 및 기타 전제조건(예를 들어 올바른 선택 항목 수)을 확인합니다. 그런 다음 휴먼 타스크 API에 대한 참조, 즉, HumanTaskManagerService를 검색합니다. 이 명령은 선택된 오브젝트에 대해 반복 실행되어 이 오브젝트를 처리합니다. 타스크는 HumanTaskManagerService API를 통해 ID별로 청구됩니다. 예외가 없는 경우 해당 TaskInstanceBean 오브젝트에 대해 상태가 갱신됩니다. 이 조치는 서버에서 오브젝트 값을 다시 검색하지 않게 합니다.
public class MyClaimCommand implements Command { public String execute(List selectedObjects) throws ClientException { if( selectedObjects != null && selectedObjects.size() > 0 ) { try { // Determine HumanTaskManagerService from an HTMConnection bean. // Configure the bean in the faces-config.xml for easy access // in the JSF application. FacesContext ctx = FacesContext.getCurrentInstance(); ValueBinding vb = ctx.getApplication().createValueBinding("{htmConnection}"); HTMConnection htmConnection = (HTMConnection) htmVB.getValue(ctx); HumanTaskManagerService htm = htmConnection.getHumanTaskManagerService(); Iterator iter = selectedObjects.iterator() ; while( iter.hasNext() ) { try { TaskInstanceBean task = (TaskInstanceBean) iter.next() ; TKIID tiid = task.getID() ; htm.claim( tiid ) ; task.setState( new Integer(TaskInstanceBean.STATE_CLAIMED ) ) ; } catch( Exception e ) { ; // Error while iterating or claiming task instance. // Ignore for better understanding of the sample. } } } catch( Exception e ) { ; // Configuration or communication error. // Ignore for better understanding of the sample } } return null; } // Default implementations public boolean isMultiSelectEnabled() { return false; } public boolean[] isApplicable(List itemsOnList) {return null; } public void setContext(Object targetModel) {; // Not used here } }