Created
June 3, 2016 13:58
-
-
Save anonymous/82511f6d80e09295238deb7d11552470 to your computer and use it in GitHub Desktop.
datepicker component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.softwareag.cis.test.customcontrols; | |
import org.xml.sax.AttributeList; | |
import com.softwareag.cis.gui.generate.ITagHandler; | |
import com.softwareag.cis.gui.generate.IXSDGenerationHandler; | |
import com.softwareag.cis.gui.protocol.Message; | |
import com.softwareag.cis.gui.protocol.ProtocolItem; | |
public class DATEPICKERHandler implements ITagHandler { | |
private String m_textprop; | |
private String m_valueprop; | |
private String m_maskprop; | |
@Override | |
public void generateHTMLForStartTag(int id, String tagName, | |
AttributeList attrlist, ITagHandler[] handlersAbove, | |
StringBuffer sb, ProtocolItem protocolItem) { | |
readAttributes(attrlist); | |
checkAttributes(protocolItem); | |
addDataBinding(protocolItem); | |
generateLayoutHTML(id, protocolItem, sb); | |
} | |
@Override | |
public void generateHTMLForEndTag(String tagName, StringBuffer sb) { | |
sb.append("\n<!-- NADC:DATEPICKER end -->\n"); | |
} | |
@Override | |
public void generateJavaScriptForInit(int id, String tagName, | |
StringBuffer sb) { | |
sb.append("csciframe.registerListener(reactOnModelUpdate" + id + ");\n"); | |
} | |
// ========================================================================= | |
// private methods | |
// ========================================================================= | |
private void readAttributes(AttributeList attributes) { | |
for (int i = 0; i < attributes.getLength(); i++) { | |
if (attributes.getName(i).equals("textprop")) | |
m_textprop = attributes.getValue(i); | |
if (attributes.getName(i).equals("maskprop")) | |
m_maskprop = attributes.getValue(i); | |
} | |
} | |
private void checkAttributes(ProtocolItem protocolItem) { | |
if (m_textprop == null || m_textprop.length() < 1) | |
protocolItem.addMessage(new Message(Message.TYPE_ERROR, | |
"Attribute TEXTPROP is not set")); | |
if (m_maskprop == null || m_maskprop.length() < 1) | |
protocolItem.addMessage(new Message(Message.TYPE_ERROR, | |
"Attribute MASKPROP is not set")); | |
} | |
private void addDataBinding(ProtocolItem protocolItem) { | |
// Property Usage | |
protocolItem.addProperty(m_textprop, "String"); | |
protocolItem.addProperty(m_valueprop, "String"); | |
protocolItem.addProperty(m_maskprop, "String"); | |
} | |
private void generateLayoutHTML(int id, ProtocolItem protocolItem, | |
StringBuffer html) { | |
html.append("<script src='./js/jquery.js'></script>"); | |
html.append("<script src='//code.jquery.com/ui/1.11.4/jquery-ui.js'></script>"); | |
html.append("<link rel='stylesheet' href='//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css'>"); | |
html.append("<span>"); | |
html.append("<input id='SIAFPICKER" + id + "' valueprop=" + m_textprop | |
+ ">"); | |
html.append("</input>"); | |
html.append("</span>"); | |
html.append("<span>" + m_valueprop + "</span>"); | |
html.append("<script>\n"); | |
html.append("$(document).ready(function() {"); | |
html.append("$('#SIAFPICKER" + id + "').datepicker();"); | |
html.append("$('#SIAFPICKER" + id | |
+ "').datepicker('setDate', '10/10/2012');"); | |
html.append("});"); | |
html.append("</script>\n"); | |
html.append("<script>\n"); | |
html.append("function reactOnModelUpdate" + id + "(model)\n"); | |
html.append("{\n"); | |
// html.append(" var vText = csciframe.getPropertyValue('"+m_textprop+"');\n"); | |
// html.append(" var vSpan = document.getElementById('NJXDEMOSPAN"+id+"');\n"); | |
// html.append(" vSpan.innerHTML = vText;\n"); | |
html.append("}\n"); | |
html.append("</script>\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment