Annotation: @ServiceMethod - TheOpenCloudEngine/metaworks GitHub Wiki

@ServiceMethod Annotation

ServiceMethod marks the annotated method could be invoked by metaworks framework and will enables the method can be invoked by web UI interface.

Options

  • callByContent is option whether the method call sends all the object contents from the client (browser) to the server. default is false for performance.
  • target is where the return value goes.
  • needToConfirm marks whether user need to confirm to commit this method by dialog Yes Or No.
  • keyBinding you can give some shortcut key mapping for this method. e.g. keyBinding="Enter"
  • mouseBinding

Returning UI Objects without changing the method interface

Using MetaworksRemoteService.wrapReturn(..)

    	import static org.metaworks.dwr.MetaworksRemoteService.*


    	@Available(condition = "metaworksContext.how == 'tree' && metaworksContext.where == 'navigator'")
    	@ServiceMethod(callByContent = true, inContextMenu = true, target = ServiceMethodContext.TARGET_APPEND)
    	public ModelResource newPractice() throws Exception {
    		this.setChildren(null);
    		
    		ModelResource resource = new PracticeResource(this);
    		resource.getMetaworksContext().setWhen(MetaworksContext.WHEN_NEW);
    		resource.setDisplayName("new practice");
    
    		if(metaworksCall()){    // 메타웍스 내에서 호출된 경우만 UI관련 포장을 함.
    			PracticeDefinerEditor editor = new PracticeDefinerEditor(session);
    			editor.load(resource);
    			
    			wrapReturn (new ToAppend(new EditorTabs(), editor)); //메타웍스에서 호출된 결과
    		}
    		
    		return resource;    // 일반적인 호출에서 얻어진 결과
    	}