Jumat, 18 Februari 2011
Berikut adalah stylesheet XSL untuk menghasilkan bentuk ExtJS (JavaScript file):
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="entity">
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var bd = Ext.getBody();
bd.createChild({tag: 'h2', html: '<xsl:value-of select="@name"/> form'});
var form = new Ext.FormPanel({
labelWidth: 150,
url:'',
frame:true,
title: 'Edit Form',
bodyStyle:'padding:5px 5px 0',
width: 500,
defaults: {width: 230},
defaultType: 'textfield',
items: [
<xsl:for-each select="attributes//attribute">{
<xsl:choose>
<xsl:when test='@type="integer"'>
xtype: 'numberfield',
</xsl:when>
<xsl:when test='@type="decimal"'>
xtype: 'numberfield',
</xsl:when>
<xsl:when test='@type="text"'>
xtype: 'textarea',
hideLabel: false,
</xsl:when>
<xsl:when test='@type="boolean"'>
xtype: 'checkbox',
</xsl:when>
<xsl:when test='@type="datetime"'>
xtype: 'datefield',
</xsl:when>
<xsl:when test='@type="timestamp"'>
xtype: 'timefield',
</xsl:when>
</xsl:choose>
fieldLabel: '<xsl:value-of select="@name"/>',
name: '<xsl:value-of select="@name"/>',
allowBlank:false
}<xsl:if test="not(position()=last())">,</xsl:if></xsl:for-each>
],
buttons: [{ text: 'Save',
handler:function() {
form.getForm().submit({
url:'/<xsl:value-of select="@name"/>/save.ashx',
method: 'POST',
success:function(form, action) {
alert('Success: ' + action.response.responseText);
},
failure:function(form, action) {
alert('Failure: ' + action.failureType);
}
});
}
},{text: 'Cancel',
handler:function() {
form.getForm().reset();
}
}]
});
form.render(document.body);
});
</xsl:template>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
</xsl:stylesheet>
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar