메타웍스 컴포넌트 만들기 - TheOpenCloudEngine/metaworks GitHub Wiki

일반 웹 페이지를 메타웍스 컴포넌트로 만들기

예제 - Accordion page

이번 예제는 jQuery Accordion을 메타웍스로 포장하는 예제이다. jQuery Accrodion은 여기에서 사용방법을 확인하여 먼저 순수 html 로 테스트를 해보는 것이 좋다 - https://jqueryui.com/accordion/

index.html 에 추가

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>

Accordion.ejs

<div id="accordion">
    <h3>Section 1</h3>
    <div>
        <p>
            Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
            ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit
            amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut
            odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.
        </p>
    </div>
    <h3>Section 2</h3>
    <div>
        <p>
            Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
            purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
            velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
            suscipit faucibus urna.
        </p>
    </div>
    <h3>Section 3</h3>
    <div>
        <p>
            Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
            Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
            ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
            lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
        </p>
        <ul>
            <li>List item one</li>
            <li>List item two</li>
            <li>List item three</li>
        </ul>
    </div>
    <h3>Section 4</h3>
    <div>
        <p>
            Cras dictum. Pellentesque habitant morbi tristique senectus et netus
            et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
            faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
            mauris vel est.
        </p>
        <p>
            Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
            Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
            inceptos himenaeos.
        </p>
    </div>
</div>

Accordion.java

package com.abc.widget;

public class Accordion {
}

Accordion.ejs.js

var com_abc_widget_Accordion = function(objectId, className){

    $( "#accordion" ).accordion();

}

테스트 하기

http://localhost:8080/runner.html?classname=com.abc.widget.Accordion

생성한 컴포넌트에 다른 컴포넌트들과 통합하기

Accordion.java

package com.abc.widget;

import com.abc.activitytype.view.AnalysisActivityView;
import org.metaworks.widget.Label;

public class Accordion {

    Object item1;
        public Object getItem1() {
            return item1;
        }
        public void setItem1(Object item1) {
            this.item1 = item1;
        }


    Object item2;
        public Object getItem2() {
            return item2;
        }
        public void setItem2(Object item2) {
            this.item2 = item2;
        }


    Object item3;
        public Object getItem3() {
            return item3;
        }
        public void setItem3(Object item3) {
            this.item3 = item3;
        }

    public Accordion(){

        setItem1(new Label("<h1>Hello world</h1>"));
        setItem2(new RadarChart());
        setItem3((new AnalysisActivityView()).createSymbol());

    }


}

Accordion.ejs

<div id="accordion">


    <h3>Section 1</h3>
    <div>
        <p>
            <%=fields.item1.here()%>
        </p>
    </div>
    <h3>Section 2</h3>
    <div>
        <p>
           <%=fields.item2.here()%>
        </p>
    </div>
    <h3>Section 3</h3>
    <div>
        <p>
            <%=fields.item3.here()%>
        </p>

    </div>
</div>
⚠️ **GitHub.com Fallback** ⚠️