/*
 * #%L
 * carewebframework
 * %%
 * Copyright (C) 2008 - 2016 Regenstrief Institute, Inc.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * This Source Code Form is also subject to the terms of the Health-Related
 * Additional Disclaimer of Warranty and Limitation of Liability available at
 *
 *      http://www.carewebframework.org/licensing/disclaimer.
 *
 * #L%
 */
package org.carewebframework.ui.angular;

import java.io.IOException;

import org.apache.commons.lang.StringUtils;
import org.zkoss.zk.au.AuResponse;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.sys.ContentRenderer;

/**
 * Container for hosting an Angular 2 component.
 */
public class AngularComponent extends HtmlBasedComponent {

    private static final long serialVersionUID = 1L;
    
    private String src;
    
    @Override
    public void renderProperties(ContentRenderer renderer) throws IOException {
        super.renderProperties(renderer);
        renderer.render("src", src);
    }
    
    @Override
    public String getZclass() {
        return _zclass == null ? "cwf-angular" : _zclass;
    }
    
    /**
     * Returns the source module containing the Angular 2 component.
     *
     * @return The source module containing the Angular 2 component.
     */
    public String getSrc() {
        return src;
    }
    
    /**
     * Sets the source module containing the Angular 2 component.
     *
     * @param src The source module containing the Angular 2 component.
     */
    public void setSrc(String src) {
        src = StringUtils.trimToNull(src);

        if (!StringUtils.equals(src, this.src)) {
            smartUpdate("src", this.src = src);
        }
    }
    
    public void ngInvoke(String functionName, Object... args) {
        _ngInvoke(functionName, args);
    }

    private void _ngInvoke(Object... args) {
        AuResponse rsp = new AuResponse("ngInvoke", this, args);
        getDesktop().getExecution().addAuResponse(rsp);
    }
}

@@ -1022,25 +1022,27 @@
 s.zk.au.
-AuRespons
+out.AuInvok
 e;%0Aimpor
@@ -1240,16 +1240,20 @@
 onent %7B%0A
+    
 %0A    pri
@@ -1298,20 +1298,16 @@
 D = 1L;%0A
-    
 %0A    pri
@@ -1323,20 +1323,16 @@
 ng src;%0A
-    
 %0A    @Ov
@@ -1499,28 +1499,24 @@
 src);%0A    %7D%0A
-    
 %0A    @Overri
@@ -1606,36 +1606,32 @@
  _zclass;%0A    %7D%0A
-    
 %0A    /**%0A     * 
@@ -1827,28 +1827,24 @@
  src;%0A    %7D%0A
-    
 %0A    /**%0A   
@@ -2073,16 +2073,24 @@
 l(src);%0A
+        
 %0A       
@@ -2196,20 +2196,16 @@
 %7D%0A    %7D%0A
-    
 %0A    pub
@@ -2302,24 +2302,28 @@
 rgs);%0A    %7D%0A
+    
 %0A    private
@@ -2366,23 +2366,21 @@
       Au
-Respons
+Invok
 e rsp = 
@@ -2385,25 +2385,29 @@
 = new Au
-Response(
+Invoke(this, 
 %22ngInvok
@@ -2413,14 +2413,8 @@
 ke%22,
- this,
  arg

Fix ngInvoke.