Animal
3 Sep 2007, 11:41 PM
OK, here's a very simple Component, the Language Maintenance page.
It only has 2 input fields. The Language Code, and the Language Name.
Here's the source JSP:
<%@ taglib uri="fclui" prefix="aspicio" %>
<%@ page language="java" pageEncoding="UTF-8"
import="java.util.Map,
com.aspicio.persistence.*,
com.aspicio.security.AspicioUser,
com.aspicio.util.PersistenceMgr,
com.aspicio.util.Utils,
com.aspicio.util.Logger,
com.aspicio.entity.base.Language"%>
<aspicio:page>
<%
Language entity = null;
final String listManagerId = request.getParameter("listManagerId");
final String entityId = request.getParameter("entityId");
Dao dao = AspicioUser.getCurrentUser().getDao();
if (entityId != null)
entity = (Language)dao.getById(Language.class, Long.parseLong(entityId));
else {
final String entityCode = request.getParameter("code");
if (entityCode != null) {
try {
entity = (Language)dao.getByCode(Language.class, entityCode);
} catch (Exception e) {
}
}
}
boolean isNew = false;
if (entity == null) {
isNew = true;
entity = new Language();
}
%>
<aspicio:form id="languageForm">
<input type="hidden" name="formEntityType" value="Language"/>
<input type="hidden" name="id" value="<%=entity.getId()%>"/>
<input type="hidden" name="version" value="<%=entity.getVersion()%>"/>
<aspicio:fieldset legend="Primary data">
<aspicio:filterfield listId="<%=listManagerId%>" entity="<%=entity%>" property="code"/>
<aspicio:textfield entity="<%=entity%>" property="name"/>
</aspicio:fieldset>
</aspicio:form>
</aspicio:page>
At the end of this post is the generated page that the browser sees.
You will not be able to run this page. The generated markup and generated script are tightly iintegrated with custom classes.
AU.initPage is a function which builds a BorderLayout in the document.body and creates the standard north, west, center and south Regions, sets up the menu according to the passed tree config, and readies the page for it's content.
The function activatePage consists of code which has been "contributed" by all the JSP tags which need to be created and activated in javascript code.
They all add their own code fragments to the overall <aspicio:page> tags handler which concats them all and puts them into this function.
The Form tags is especially complex. It collects its nested input fields, and creates an array of fields. Each input handling tag outputs an anonymous function which creates, and initializes and returns the javascripts widget, so you'll see the "fields" array looking like
var fields = [
function() {
var f = new Ext.form.TextField();
// preprocess f
return f;
}(),
function() { blah){}
];
Each field is applied to a field that the input field's tag hander output as HTML with a unique, generated ID.
We have to generate all IDs because of the nature of popup key lookup windows. Each lookup pops up the full maintenance Component for the desired table, so any page may exist in the document more than once. So no ids can be referenced. This probably happens a lot in "Ajax" apps. Dynamic loading from the same URL more than once causing id clashes. Our tags generate all ids.
In script, you can see that all the scripts are within the same scope They are executed in the scope of a ComponentPanel widget (activatePage.call(cp); where cp is the ComponentPanel, a subclass of ContentPanel) through which access to the form, and fields within that form is possible.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head>
<link rel="shortcut icon" href="/aspicio/images/Aspicio.ico" type="image/x-icon"/>
<script type="text/javascript" src="/aspicio/dwr/engine.js"></script>
<script type="text/javascript" src="/aspicio/dwr/interface/AspicioUtils.js"></script>
<script type="text/javascript" src="/aspicio/js/JavascriptMessages.js"></script>
<script type="text/javascript" src="/aspicio/js/Aspicio.js"></script>
<script type="text/javascript" src="/aspicio/dwr/interface/ListHelper.js"></script>
<script type="text/javascript">
var cp;
Ext.BLANK_IMAGE_URL='/aspicio/images/s.gif';
function initializePage() {
AU.initAspicio(null
,{
text:'Nige\u0027s Menu!',id:1,
className:'Menu',
iconCls: 'folder',
expanded:true,
allowDrag:false,
leaf:false,
children:[
{
text:'Static Data',id:3,
className:'Menu',
iconCls: 'folder',
expanded:false,
allowDrag:false,
leaf:false,
children:[
{
text:'EconomicGroup Maintenance',id:9,
className:'Menu',
icon:'/aspicio/images/entity/EconomicGroup.gif',
componentId:23,
href:'/aspicio/AspComponent.get?component=EconomicGroup',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Language Maintenance',id:7,
className:'Menu',
icon:'/aspicio/images/entity/Language.gif',
componentId:21,
href:'/aspicio/AspComponent.get?component=Language',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Person Maintenance',id:31,
className:'Menu',
icon:'/aspicio/images/entity/Person.gif',
componentId:51,
href:'/aspicio/AspComponent.get?component=Person',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'UserGroup Maintenance',id:11,
className:'Menu',
icon:'/aspicio/images/entity/UserGroup.gif',
componentId:26,
href:'/aspicio/AspComponent.get?component=UserGroup',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'TimeZone Maintenance',id:10,
className:'Menu',
icon:'/aspicio/images/entity/TimeZone.gif',
componentId:24,
href:'/aspicio/AspComponent.get?component=TimeZone',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Country Maintenance',id:21,
className:'Menu',
icon:'/aspicio/images/entity/Country.gif',
componentId:29,
href:'/aspicio/AspComponent.get?component=Country',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'User Maintenance',id:27,
className:'Menu',
icon:'/aspicio/images/entity/User.gif',
componentId:32,
href:'/aspicio/AspComponent.get?component=User',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Menu Maintenance',id:30,
className:'Menu',
icon:'/aspicio/images/entity/Menu.gif',
componentId:49,
href:'/aspicio/AspComponent.get?component=Menu',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
} ]
},{
text:'New Menu',id:12,
className:'Menu',
iconCls: 'folder',
expanded:false,
allowDrag:false,
leaf:false,
children:[
{
text:'Language Maintenance',id:13,
className:'Menu',
icon:'/aspicio/images/entity/Language.gif',
componentId:21,
href:'/aspicio/AspComponent.get?component=Language',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Currency Maintenance',id:14,
className:'Menu',
icon:'/aspicio/images/entity/Currency.gif',
componentId:22,
href:'/aspicio/AspComponent.get?component=Currency',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'EconomicGroup Maintenance',id:15,
className:'Menu',
icon:'/aspicio/images/entity/EconomicGroup.gif',
componentId:23,
href:'/aspicio/AspComponent.get?component=EconomicGroup',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'TimeZone Maintenance',id:16,
className:'Menu',
icon:'/aspicio/images/entity/TimeZone.gif',
componentId:24,
href:'/aspicio/AspComponent.get?component=TimeZone',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'GeneralAnalysis Maintenance',id:17,
className:'Menu',
icon:'/aspicio/images/entity/GeneralAnalysis.gif',
componentId:25,
href:'/aspicio/AspComponent.get?component=GeneralAnalysis',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'UserGroup Maintenance',id:18,
className:'Menu',
icon:'/aspicio/images/entity/UserGroup.gif',
componentId:26,
href:'/aspicio/AspComponent.get?component=UserGroup',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Country Maintenance',id:19,
className:'Menu',
icon:'/aspicio/images/entity/Country.gif',
componentId:29,
href:'/aspicio/AspComponent.get?component=Country',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Player Maintenance',id:20,
className:'Menu',
icon:'/aspicio/images/entity/Player.gif',
componentId:30,
href:'/aspicio/AspComponent.get?component=Player',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
} ]
},{
text:'Security Menu',id:25,
className:'Menu',
iconCls: 'folder',
expanded:false,
allowDrag:false,
leaf:false,
children:[
{
text:'Generic Security Maintenance',id:26,
className:'Menu',
icon:'/aspicio/images/entity/GSMSecurity.gif',
componentId:46,
href:'/aspicio/AspComponent.get?component=GSMSecurity',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
} ]
},{
text:'Personal',id:288,
className:'Menu',
iconCls: 'folder',
expanded:false,
allowDrag:false,
leaf:false,
children:[
{
text:'Domain Maintenance',id:328,
className:'Menu',
icon:'/aspicio/images/entity/Domain.gif',
componentId:59,
href:'/aspicio/AspComponent.get?component=Domain',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
},{
text:'Cycling News!',id:290,
className:'Menu',
icon:'/aspicio/images/entity/Menu.gif',
href:'http://www.cyclingnews.com/',
expanded:false,
allowDrag:false,
leaf:true,
children:[
]
} ]
} ]
});
var cp=AW.ComponentPanel.getParentPanel("page-content");
cp.setComponent('LanguageDetails');
cp.setTitle('Language Details');
cp.setEntityType('Language');
cp.setParentEntityType('Language');
cp.hasPopupSubcomponents=false;
cp.hasTabSubcomponents=false;
function activatePage() {
var fields=[
function(){
var b=Ext.get('AspicioForm1188890329375FilterField0FindButton');
var f=new Ext.form.TextField({ id:'AspicioForm1188890329375FilterField0',
name:'code',
helpKey:'Language.code',
forceUpperCase:true,
validatorMask:/[A-Za-z0-9]{1,10}/,value:''}).applyTo('AspicioForm1188890329375FilterField0');
b.on('click', function(){cp.supercomponent.searchOnFieldValue('AspicioForm1188890329375FilterField0');})
f.on({});
return f;}(),
function(){var f=new Ext.form.TextField({ id:'AspicioForm1188890329375TextField1',
name:'name',
helpKey:'Language.name',
allowBlank:false,
validatorMask:/[A-Za-z0-9 ]{1,50}/,value:''}).applyTo('AspicioForm1188890329375TextField1');
f.on({});
return f;}()];
this.domForm=Ext.getDom('AspicioForm1188890329375');
this.form=new Ext.form.BasicForm(this.domForm,{
id:'AspicioForm1188890329375',
url:'null',
method:'POST'
});
Ext.ComponentMgr.register(this.form);
this.form.add.apply(this.form, fields);
this.form.on('beforeAction',function(f,a){
if((a.type == 'submit') && !f.areFieldsValid()){
aspicio.util.displayMessage('Some fields are invalid or incomplete and must be corrected before you can save any changes.', aspicio.util.ERROR);
f.highlightInvalid();
return false;
}});
Ext.get('AspicioForm1188890329375').on('submit',function(e){
e.stopEvent();
this.submit();
},this.form);
this.postProcessUI();
}//end activatePage
activatePage.call(cp);
cp.setSubcomponents([]);
AW.pageLayout.layout();
}
Ext.onReady(initializePage);
</script>
<style type="text/css">@import url("/aspicio/css/Aspicio.css");
</style></head>
<body scroll="no"
>
<div id="page-header"><div id="page-title-container" class="x-layout-panel-hd"><div id="page-titlebar"> </div><div id="page-toolbar"></div></div><div id="aspicio-menu-bar"></div>
</div>
<div id="page-content">
<form class="x-form " name="AspicioForm1188890329375" id="AspicioForm1188890329375" method="POST" ><input type="hidden" name="formEntityType" value="Language"/>
<input type="hidden" name="id" value="null"/>
<input type="hidden" name="version" value="null"/>
<fieldset class="x-form-fieldset x-form-label-left " ><legend>Primary data</legend><div class="x-form-item"><label style="width:100px" for="AspicioForm1188890329375FilterField0">Code</label><div class="x-form-element asp-form-element"><input name="code" id="AspicioForm1188890329375FilterField0" class="x-form-text " style="text-transform:uppercase;" size="3" maxlength="3" ><button type="button" tabindex="-1" class="asp-drill-button" id="AspicioForm1188890329375FilterField0FindButton">Find</button></div></div>
<div class="x-form-item"><label style="width:100px" for="AspicioForm1188890329375TextField1">Name</label><div class="x-form-element asp-form-element"><input name="name" id="AspicioForm1188890329375TextField1" class="x-form-text " size="50" maxlength="50" ></div></div></fieldset></form>
</div>
<div id="page-message">
</div></body></html>
That's the code that is produced if that JSP page is requested directly from the browser's navigation bar as a main page.
The app is single page, so usually, that Component will be Ajax-loaded through an XHR. Whan that happens the page handling tag does NOT produce a full HTML document with script to create a BorderLayout etc. Instead it produces script to just put that page into the content area that was generated when the app was first loaded.
The HTML which constitutes the actual page content is the same though:
<div id="AspicioPage1188890323046" style="outline:0px none;" >
<script type="text/javascript">
var cp=AW.ComponentPanel.getParentPanel("AspicioPage1188890323046");
cp.setComponent('LanguageDetails');
cp.setTitle('Language Details');
cp.setEntityType('Language');
cp.setParentEntityType('Language');
cp.hasPopupSubcomponents=false;
cp.hasTabSubcomponents=false;
function activatePage(){
var fields=[
function(){
var b=Ext.get('AspicioForm1188890323062FilterField0FindButton');
var f=new Ext.form.TextField({ id:'AspicioForm1188890323062FilterField0',
name:'code',
helpKey:'Language.code',
forceUpperCase:true,
validatorMask:/[A-Za-z0-9]{1,10}/,value:''}).applyTo('AspicioForm1188890323062FilterField0');
b.on('click', function(){cp.supercomponent.searchOnFieldValue('AspicioForm1188890323062FilterField0'
);})
f.on({});
return f;}(),
function(){var f=new Ext.form.TextField({ id:'AspicioForm1188890323062TextField1',
name:'name',
helpKey:'Language.name',
allowBlank:false,
validatorMask:/[A-Za-z0-9 ]{1,50}/,value:''}).applyTo('AspicioForm1188890323062TextField1');
f.on({});
return f;}()];
this.domForm=Ext.getDom('AspicioForm1188890323062');
this.form=new Ext.form.BasicForm(this.domForm,{
id:'AspicioForm1188890323062',
url:'null',
method:'POST'
});
Ext.ComponentMgr.register(this.form);
this.form.add.apply(this.form, fields);
this.form.on('beforeAction',function(f,a){
if((a.type == 'submit') && !f.areFieldsValid()){
aspicio.util.displayMessage('Some fields are invalid or incomplete and must be corrected before you
can save any changes.', aspicio.util.ERROR);
f.highlightInvalid();
return false;
}});
Ext.get('AspicioForm1188890323062').on('submit',function(e){
e.stopEvent();
this.submit();
},this.form);
;
}//end activatePage
activatePage.call(cp);
cp.setSubcomponents([]);
</script>
<form class="x-form " name="AspicioForm1188890323062" id="AspicioForm1188890323062" method="POST"
><input type="hidden" name="formEntityType" value="Language"/>
<input type="hidden" name="id" value="null"/>
<input type="hidden" name="version" value="null"/>
<fieldset class="x-form-fieldset x-form-label-left " ><legend>Primary data</legend><div class="x-form-item"
><label style="width:100px" for="AspicioForm1188890323062FilterField0">Code</label><div class="x-form-element
asp-form-element"><input name="code" id="AspicioForm1188890323062FilterField0" class="x-form-text
" style="text-transform:uppercase;" size="3" maxlength="3" ><button type="button" tabindex="-1" class
="asp-drill-button" id="AspicioForm1188890323062FilterField0FindButton">Find</button></div></div>
<div class="x-form-item"><label style="width:100px" for="AspicioForm1188890323062TextField1">Name</label
><div class="x-form-element asp-form-element"><input name="name" id="AspicioForm1188890323062TextField1"
class="x-form-text " size="50" maxlength="50" ></div></div></fieldset></form>
</div>
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.