向EOS中添加自定义页面控件一用户需求在项目中客户要求能够_第1页
向EOS中添加自定义页面控件一用户需求在项目中客户要求能够_第2页
向EOS中添加自定义页面控件一用户需求在项目中客户要求能够_第3页
免费预览已结束,剩余1页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、向EOS中添加自定义页面控件用户需求在项目中,客户要求能够向Studio的JSP编辑器中添加自定义的页面控件。Studio的JSP编辑器也提供了扩展机制来允许用户添加自定义页面控件,但这需要对Studio的控件模板的执行机制有较深入的了解。本文介绍如何利用 Studio提供的扩展机制来添加用户自定义的页面控件,以期对后续 遇到类似需求的同学有所帮助。解决方案下面详细列出解决方案的具体步骤:1.编写自定义控件的模板根据用户的需求,编写满足用户需求的控件模板。在EOS实现内部,我们使用Velocity模板机制;因此所编写的控件模板必须使用Velocity模板语言。如下所示是EOS提供的Record

2、View控件的模板:#if($map.get("recordview")!="")#set($map=$map.get("recordview")#end#set($title=$map.get("title")#set($e ntityTable=$map.get("e ntityTable") #set($row_le ngth=$map.get("rowLe ngth")#set($xpath=$map.get("xpath")#set($width

3、="100%")#set($width=$map.get("width")$WizardReverseHelper.getComp onen tTag("coship_recordview",$map)<w:panel id="panel1" width="$width" title="$title"><tablealig n="ce nter"border="0" width="100%" cla

4、ss="form_table">#set($curre ntRowCou nt = $row_le ngth)#foreach($row in 1.$e ntityTable.getCou ntSize()#set($tagEleme nt =$e ntityTable.getTagCo nfig($row)#if($e ntityTable.getCell($row,5)=true)#if($curre ntRowCou nt=$row_le ngth)<tr>#end#set($curre ntColspa n = 1)#set($curre ntRo

5、wField = $e ntityTable.getCell($row,4) #if($curre ntRowField=1)#if($row<$e ntityTable.getCou ntSize()#set($curre ntColspa n = 1)#else#set($curre ntColspa n = $curre ntRowCou nt * 2 - 1) #end#set($curre ntRowCou nt = $curre ntRowCou nt - 1)#else#if($curre ntRowCou nt<=$curre ntRowField)#set($cu

6、rre ntColspa n = $curre ntRowCou nt * 2 - 1) #set($curre ntRowCou nt=O)#else#set($curre ntColspa n= $curre ntRowField * 2 - 1) #set($curre ntRowCou nt = $curre ntRowCou nt -$curre ntRowField)#end#end<td class="form_label">$e ntityTable.getCell($row,2)v/td> <td#if($curre ntColsp

7、a n 匸 1) colspa n="$curre ntColspa n"#end> #set($temp=$tagEleme nt.removeAttribute("iterateld") #if($xpath !="")#set($property_ name=$TagEleme ntHelper.getAttributeValue($t agEleme nt, "property")$TagEleme ntHelper.setAttributeValue($tagEleme nt,"prope

8、rty", "$xpath/$property_ name")#end$tagEleme nt.toStri ng(true,true)</td>#if($row=$e ntityTable.getCou ntSize()</tr>#else#if($curre ntRowCou nt=O)</tr>#set($curre ntRowCou nt = $row_le ngth)#end#end#end#end</table></w:pa nel>$WizardReverseHelper.getComp o

9、nentEn dTag("coship recordview")2.实现一个Eclipse插件由于Studio的JSP编辑是通过Eclipse的扩展点机制来实现其扩展功能的。因此,我们需要在Eclipse的PDE插件开发环境中新建一个Eclipse插件,如:com.primeton.studio.coship 。新 建插件 需要对 com.primeton.studio.jsp.core 、com.primeton.studio.jsp.tag、com.primeton.studio.template.core 插件建立依赖关系。3. 注册自定义模板在新建的插件中,通过co

10、m.primeto n.studio.template.core.template 扩展点来向Studio中注册自定义的模板,如下所示:一com. parstudi o. teimplate- c&r电-templateaaa-®田ffi'-fflEh£ X Cship Composite: Component (category Queryform (category) Vi ewLi st (category) Datsfarm (cat色gory) Re c ar dlV iew1 (c at e gory)ReeariView Composi te

11、Ceimponent (t创X RecordVi ew Reverse Confi g (template)内容如下:Ext&nsi on El»ent DetailsS«t the properties of tswplate模板文件id*:ctJiki p_r *cor dvi awdeployjath*:Brcvst,.t empl at e s/p age de7ftl op/c ompt /R« cordVi ew vwiddabl«*:aditablA*:r fem oveable*:Kame* :descr ipti an:fals

12、 ftcordVi ewCompositECompansnt4. 向JSP编辑器中注册选项板元素在新建的插件中,通过com.primeto n.studio.jsp.ui.paletteGroups扩展点来向 Studio的JSP注册选项板元素,如下所示:- 8 com. prime ton. studio, jsp. ui. paletteGroxips二 |x Coship Composite Component (palettGroup)QueryFormDataForm (paletteltem)Vi eListRecordVi ew内容如下:Zxtensiffn Eleaent De

13、tailsSet the propertic£ "pilett&Itah"ru/n e*:ternplat eld*:Mi all" on:RecordVi e*eashi p r ecor dvi ewi cons/r c/r«c*>r dvi sw. gi fBrowse.Brcwsfi-.i cons/rc/recordvi ew.Browse.coship/CcshipRsccr dVie. xr*l5. 实现并注册模板执行器在新建插件中实现一个模板执行器类,该类需要实现ITemplateExecuter 接口,Studi

14、o已经默认提供了一个模板执行器 DefaultTagTemplateExecuter,如没有特殊要 求的话,你可以直接使用这个默认的模板执行器。实现了模板执行器后,我们需要通过扩展点 com.primet on. studio.template.core.templateExecuter来向系统中注册我们的模板执行器,如下所示:HiHkIKiIK一 =0= coin, prime ton- studi o. tempi ate- core, t empl at eEx e cut er c o shi p_q.ueryfciriin Cex e cut er j coship_dataform

15、 (escecuter) coshipvist (xecutercoship_rec&rdvi sx (extcuter)内容如下:Extents i<nik Elen ent DetailsSet the properties of6.部署插件到Studio在Eclipse中导出新开发的插件 com.primeton.studio.coship ,将其部署到EOS产品安 装目录中的 ideeostoolseclipseplugins 目录中。经过上述步骤后,我们注册的页面控件就可以在JSP编辑器中看到了,在选项板中选取我们注册的页面控件,然后在JSP编辑器中合适的位置放置该元素

16、,此时,我们的控件模板将被执行,执行后的结果将被插入到刚刚所选择的页面位置。为了带给用户更好的体验,我们通常需要为控件提供向导,以方便用户对控件属性 进行设置。下面我们介绍如何为控件提供向导。7.高级特性:为控件提供向导为了提供控件向导,我们需要提供三个类:(1) 向导类:该类必须实现ICreationWizard接口,用户可以扩展 EOS提供的AbstractCompositeTagCreatio nWizard来实现向导类。(2) 向导组件构造器:该类用来绘制向导的UI,该类必须实现IControlFactory工厂。用户可以扩展EOS提供的AbstractViewComposite来实现

17、向导组件构造器。(3) 向导动作处理器:该类用来执行向导的动作,如:完成、取消。该类必须实现 IWizardHandler 接口。实现上述三个类后,需要通过com.primeto n.studio.jsp.ui.paletteWizard扩展点来向系统中注册这个向导,如下所示:总或北 com. primieton. studio, jsp. ui_paletttfizardlXj coship_ue;ryformzardCc>nfi g)jiF co ski p_dat 息f oTim (wi zardConf i g) X coEhip vi ewlist (wizardConf i

18、g)coshi p_r ecor dvi ew Gri dConfig)j_内容如下:Extendi qu Elesent DetailsSet the properties o£ wizardConfi g*id*:co生hip recordview1" "- 一一一一一一一 一一一一一一 一 cIa-es#:com. primeton. studio, coship. wizard. CoshipRe-cordVi ewWizard' Brows*.11i1factorv*:coii. primiton. studi o, jsp. tag, wizard, recordvi ew. R«cord¥i swCcmp;Brws«.11 han

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论