Extending Metaworks Components - TheOpenCloudEngine/metaworks GitHub Wiki
λ©νμμ€ μ»΄ν¬λνΈμ μμκ°λ
λ©νμμ€ μ»΄ν¬λνΈμ ꡬμ±
λ©νμμ€ μ»΄ν¬λνΈλ model-face-facehelper (java, ejs, ejs.js) λ‘ κ΅¬μ±λλ€. κ°μλ λμΌ ν¨ν€μ§ (ν΄λ, λλ ν 리) μμ μ‘΄μ¬ν΄μΌ μλ‘ λ¬Άμ΄κ² λλ€. ejs νμΌμ΄ μμ΄λ κΈ°λ³Έ ejs λ‘ ObjectFace.ejs κ° μ¬μ©λκ² λμ΄ λͺ¨λΈμ 리νλμ μΌλ‘ νλ©΄μ λΏλ¦¬κ² λλ€.
[Model.java]
|
[Model.ejs] - optional (java λ κΌ μμ΄μΌ ν¨. ejs λ§ μ‘΄μ¬νλ component λ μμ)
|
[Model.ejs.js] - optional (ejs.js κ° μλ€λ©΄ ejs λ κΌ μμ΄μΌ ν¨)
Model.java
package com.abc.model;
public class Model{
String field1;
public getField1(){ return field1;}
public setField1(String field1){ this.field1 = field1; }
}
Model.ejs
Field1 = <%=value.field1%>
Model.ejs.js
var com_abc_model_Model = function(objectId, className){
$("#objDiv_" + objectId).css("background", "yellow");
};
UIμ μμ
DerivedModel.java
μλμ derivedModel μ μμ μ ejsμ ejs.js κ° μμ΄λ Model μ΄ κ°μ§ Model.ejs μ Model.ejs.js κΉμ§ μμ λ°κ² λλ€. μ¦, UIλ₯Ό λͺ¨λ μμ λ°λλ€.
class DerivedModel extends Model{
String field2;
public getField2(){ return field2;}
public setField2(String field2){ this.field2 = field2; }
}
UIμ μ€λ²λΌμ΄λ
DerivedModel.ejs νμΌμ λ§λ€μ΄ λμΌ ν΄λμ λ£μ΄μ£Όλ©΄, DerivedModel μ μμ μ ejsμ ejs.js λ₯Ό λ°λ₯΄κ² λλ€. μ΄ λ κΈ°μ‘΄ νλ©΄ ejs λ₯Ό κ°μ Έμμ μΆκ°λ μμλ§μ λ£κ³ μΆμ κ²½μ°λΌλ©΄, include λ₯Ό μ¬μ©νλ€.
DerivedModel.ejs μμ
<%=include('dwr/metaworks/com/abc/model/Model.ejs')%>
<%=fields.field2.here()%>
Face Helper λ₯Ό μμνλ €λ©΄ λ€μκ³Ό κ°μ΄ metaworks μμ μ μν΄μ£Όλ extend λ©μλλ₯Ό μ¬μ©νλ€.
DerivedModel.ejs.js
var com_abc_model_DerivedModel = function(objectId, className){
com_abc_model_Model.apply(this, new Array(objectId, className)); //equals to super(objectId, className) in java
}
extend(com_abc_model_DerivedModel, "com_abc_model_Model"); //equals to extends in java