123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- XFormsBindableControl.prototype = new XFormsControl;
- function XFormsBindableControl (strParentId, strAlert, strHelp, strHint, strAccesskey, strBind, strClass,
- bDisabled, strId, nNavindex, strRef, strStyle, strTag, strVisibility, strUserDefineAttrib)
- {
- if (!strId)
- {
- return;
- }
-
- XFormsControl.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, strClass,
- bDisabled, strId, nNavindex, strStyle, strTag, strVisibility, strUserDefineAttrib);
-
- /**
- * Property
- */
- this.value = "";
-
- /**
- * Attribute
- */
- this.attribute["bind"] = strBind;
- this.attribute["ref"] = strRef;
- this.attribute["required"] = null;
-
- this.m_xlRefNode = null;
- this.m_bBinded = false;
- this.m_bCanBind = true;
-
- this.m_bBase64 = false;
-
- var strBind = this.getAttribute("bind");
- //bind obj 찾기
- if (null != strBind && !strBind.isEmpty())
- {
- this.m_bBinded = true;
- }
-
- var strRef;
- if (BT_SINGLE == this.getBindingType())
- {
- strRef = this.getAttribute("ref");
- }
- else if (BT_NODESET == this.getBindingType())
- {
- strRef = this.getAttribute("nodeset");
- }
-
- if (null != strRef && !strRef.isEmpty())
- {
- if (null == REF_ATTRIBUTE[strRef])
- {
- REF_ATTRIBUTE[strRef] = new Hashtable();
- REF_ATTRIBUTE[strRef][this.id] = this;
- }
- else
- {
- REF_ATTRIBUTE[strRef][this.id] = this;
- }
- this.m_bBinded = true;
- }
- };
- XFormsBindableControl.prototype.init = function ()
- {
- XFormsControl.prototype.init.call(this);
-
- this.m_xlRefNode = this.getControlNodeList();
- };
- XFormsBindableControl.prototype.refresh = function ()
- {
- XFormsControl.prototype.refresh.call(this);
-
- this.m_xlRefNode = this.getControlNodeList();
- };
- XFormsBindableControl.prototype.getRefNode = function ()
- {
- return this.m_xlRefNode;
- };
- XFormsBindableControl.prototype.setRefNode = function (xlNode)
- {
- this.m_xlRefNode = xlNode;
- };
- XFormsBindableControl.prototype.isBinded = function ()
- {
- return this.m_bBinded;
- };
- XFormsBindableControl.prototype.setBinded = function (bBinded)
- {
- this.m_bBinded = bBinded;
- };
- XFormsBindableControl.prototype.isCanBind = function ()
- {
- return this.m_bCanBind;
- };
- XFormsBindableControl.prototype.setCanBind = function (bCanBind)
- {
- this.m_bCanBind = bCanBind;
- };
- XFormsBindableControl.prototype.getValue = function ()
- {
- // 부모가 그리드, 멀티라인 그리드 일때 처리
- if (false/* "datagrid" == this.parent.getElementName */)
- {
- // return this.parent.getValue();
- }
- else
- {
- this.m_xlRefNode = this.getControlNodeList();
-
- if (null != this.m_xlRefNode && 0 < this.m_xlRefNode.length)
- {
- return XmlLib.getTextValue(this.m_xlRefNode.item(0));
- }
-
- // 없을때 처리
- if ("xforms:caption" == this.getElementName())
- {
- return this.getText();
- }
- else if ("xforms:button" == this.getElementName())
- {
- return this.getText();
- }
- else if ("xforms:treeview" == this.getElementName())
- {
- return this.getText();
- }
-
- return "";
- }
- };
- XFormsBindableControl.prototype.setValue = function (strValue)
- {
- //TODO Parent 부분 처리
- if (null != this.m_xlRefNode && 0 < this.m_xlRefNode.length)
- {
- var xnNode = this.m_xlRefNode.item(0);
-
- // TODO valid check
- // TODO CDATA 처리
-
- var bAutoCDATA = model.attribute["autocdata"];
- var bProcessCDATA = model.isProcessAutoCdata(strValue);
- if (bAutoCDATA && bProcessCDATA)
- {
- //TODO model 의 autocdata 처리
- }
- else
- {
- XmlLib.setTextValue(xnNode, strValue);
- }
- }
- else
- {
- this.setText(strValue);
- }
-
- this.refreshCurrentModel(this.attribute["ref"]);
- };
- XFormsBindableControl.prototype.getControlNodeList = function ()
- {
- if (null == model)
- {
- return null;
- }
-
- var strBind = this.getAttribute("bind");
- if (null != strBind && !strBind.isEmpty())
- {
- // TODO bind 처리
- this.m_bBinded = true;
- }
- else
- {
- var strRef;
- if (BT_SINGLE == this.getBindingType())
- {
- strRef = this.getAttribute("ref");
- }
- else if (BT_NODESET == this.getBindingType())
- {
- strRef = this.getAttribute("nodeset");
- }
-
- if (null != strRef && !strRef.isEmpty())
- {
- this.m_bBinded = true;
- return model.getInstancePart(null, strRef);
- }
- }
- return null;
- };
- /**
- * Attribute 값을 변경시키고 Attribute 값 변화에 맞는 동작을 수행한다.
- * @param strAttribute
- * @param strValue
- * @return
- */
- XFormsBindableControl.prototype.setAttribute = function (strAttribute, strValue)
- {
- XFormsControl.prototype.setAttribute.call(this, strAttribute, strValue);
- switch (strAttribute)
- {
- case "bind" :
- {
- this.attribute["bind"] = strValue;
- break;
- }
- case "ref" :
- {
- var strRef = this.attribute["ref"];
- if (null != strRef && !strRef.isEmpty())
- {
- if (null != REF_ATTRIBUTE[strRef])
- {
- REF_ATTRIBUTE[strRef][this.id] = null;
- }
- }
- this.attribute["ref"] = strValue;
- if (null != strValue && !strValue.isEmpty())
- {
- if (null == REF_ATTRIBUTE[strValue])
- {
- REF_ATTRIBUTE[strValue] = new Hashtable();
- REF_ATTRIBUTE[strValue][this.id] = this;
- }
- else
- {
- REF_ATTRIBUTE[strValue][this.id] = this;
- }
- this.m_bBinded = true;
- }
- break;
- }
- }
- };
- XFormsBindableControl.prototype.isBindControlByNode = function (xnNode)
- {
- this.m_xlRefNode = this.getControlNodeList();
-
- if (null != this.m_xlRefNode)
- {
- for (var i=0; i<this.m_xlRefNode.length; i++)
- {
- var xnRefNode = this.m_xlRefNode.item(i);
- if (xnNode == xnRefNode)
- {
- return true;
- }
- }
- }
- return false;
- };
- XFormsBindableControl.prototype.isBindControlByXPath = function (strXPath)
- {
- var strRef;
- if (BT_SINGLE == this.getBindingType())
- {
- strRef = this.getAttribute("ref");
- }
- else if (BT_NODESET == this.getBindingType())
- {
- strRef = this.getAttribute("nodeset");
- }
-
- return (strRef == strXPath);
- };
- XFormsBindableControl.createAttribute = function (xnHtmlNode, clAttribute)
- {
- xnHtmlNode = XFormsControl.createAttribute(xnHtmlNode, clAttribute);
- return xnHtmlNode;
- };
|