PDA

View Full Version : problem in reading a html hidden field value in ext js! help needed



shyam63
24 Oct 2011, 6:25 AM
Hi,

i have jsp file which contains a hidden field. and jsp files import the js files which has form and form elements.
i have a problem in reading the html hidden field value in ext js.
i tried using
document.getElementById('idname') ans also through
Ext.get('idname')
but i am always getting "null" as value.
can u please find from below code what's exactly causing the issue?
<html>
JSP CODE

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Termination Data</title>
<link rel="stylesheet" type="text/css" href="<c:url value="/css/style.css" />" media="all" />
<link rel="stylesheet" type="text/css" href="<c:url value="/js/ext-4.0/resources/css/ext-all.css" />">
<script type="text/javascript" src="<c:url value="/js/ext-4.0/ext-debug.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/ext-4.0/ext-all-debug.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/ext-4.0/ext-dev.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/ext-4.0/ext.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/ext-4.0/ext-all.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/ext-4.0/script_termination_data.js"/>"></script>
</head>
<body>
<table width="100%" align="center">
<tr>
<td width="100%" align="center" style="padding-top:100px;">
<div id="terminationDataDiv"><input type="hidden",id="frmurl", value="${flowExecutionUrl}"></input></div>
</td>
</tr>
</table>
</body>
</html>




JavaScript File code


Ext.require([ 'Ext.form.*'
]);


Ext.onReady(function(){


//var url = Ext.get('frmurl');
var url = document.getElementById("formurl");
alert('url='+url);
Ext.define('Level', {
extend: 'Ext.data.Model',
fields: [
{type: 'string', name: 'abbr'},
{type: 'string', name: 'name'}
]
});


var Levels = [
{"abbr":"1","name":"Level1"},
{"abbr":"2","name":"Level2"},
{"abbr":"3","name":"Level3"},
{"abbr":"4","name":"Level4"}

];



// The data store holding the Levels
var store = Ext.create('Ext.data.Store', {
model: 'Level',
data: Levels
});
var trmData = new Ext.form.FormPanel({
standardSubmit: true,
frame:true,
title: 'Termination Data',
width: 600,
bodyPadding: 5,
fieldDefaults: {
labelAlign: 'left',
anchor: '100%',
labelWidth: 150
},
//url: url,
items: [
{
xtype: 'textfield',
name: 'name',
fieldLabel: 'NAME'
},
{
xtype: 'textfield',
name: 'id',
fieldLabel: 'ID'
},
{
xtype: 'datefield',
name: 'terminationData',
fieldLabel: 'TERMINATION DATA'
},
{
xtype: 'datefield',
name: 'lastDayWorked',
fieldLabel: 'LAST DAY WORKED'
},
{
xtype: 'combobox',
name: 'replacementLevel',
fieldLabel: 'REPLACEMENT LEVEL',
store: store,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr'
},
{
xtype: 'textarea',
name: 'replacementReason',
fieldLabel: 'REPLACEMENT REASON'
},
{
xtype: 'hidden',
name: 'replacementReason',
fieldLabel: 'REPLACEMENT REASON'
}
],
buttons:[
{
text: 'Back to DashBoard',
handler: function() {
var form = this.up('form').getForm();
form.submit({
params:{name:'_eventId_back'},
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
}
},
{
text: 'Cancel',
handler: function() {
this.up('form').getForm().reset();
}
},
{
text: 'Save As Draft'
},
{
text: 'Save And Continue',
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
params:{name:'_eventId_continue'},
success: function(form, action) {
Ext.Msg.alert('Success', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('Failed', action.result.msg);
}
});
}
}
}
]
});
trmData.render('terminationDataDiv');

});