- 浏览: 497190 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (185)
- job (15)
- linux/windows/unix/bash/shell (31)
- JAVA/J2EE/spring/hibernate/struts (30)
- VC/C++ (48)
- mysql/postgresql (6)
- php/jsp/asp/pear (1)
- FMS/flex/openlaszlo/red5/openmeetings (34)
- apache/tomcat/ftp/svn (6)
- xen/vm/Hadoop/cloudcompute (6)
- visual studio/eclipse/zendstudi/ant (8)
- others (1)
- windows异常处理 __try __except (1)
- (1)
- matlab (4)
- android (0)
最新评论
-
hongzhounlfd:
很透彻,很详细
依赖注入和控制反转 -
jefferyqjy:
谢谢~言简意赅~很明了!
依赖注入和控制反转 -
elderbrother:
太好了,谢谢
依赖注入和控制反转 -
east_zyd_zhao:
终于搞明白了
依赖注入和控制反转 -
Dremeng:
完美,一看就懂理解透彻
依赖注入和控制反转
Combining Tags and Script in LZX Programs (openlaszlo)
As mentioned earlier, virtually all nontrivial LZX programs contain both (XML) tags and script. Tags are used declaratively, that is, to define objects and their attributes. Script is used procedurally, that is, to explicitly define a series of steps. Although the two kinds of code are liberally intermixed within LZX — for example, script can appear within tags — each syntax locally maintains its integrity.
So for example, within declarative LZX code, comments are denoted
<!-- XML comment -->
while within JavaScript, comments are denoted
// JavaScript comment
Thus LZX is similar to an alloy of two metals that do not chemically combine.
Because the declarative and procedural portions of a program can be so intertwined, it can be a little tricky, at first, to recognize them within a program. However, once you gain a little experience and begin to grasp the underlying logic of LZX you will find that you hardly notice the alternating syntaxes. The following paragraphs explain how and why to employ the two "flavors" of LZX. Consult the documentation for your IDE or text editor to learn how to use the LZX DTD or schema to give visual cues that indicate what portions of the program are in each syntax.
The preferred normalized form of class names is lz.[tagname]
where [tagname] is the name of a tag. So for example a if you created a class called "bob":
<class name="bob"/>
then from the point of view of JavaScript, this would be an lz.bob object.
In earlier versions of LZX (before OpenLaszlo 4), there was an asymmetric mapping between tag and class names, often of the form LzFoo <—> <foo>, as in the correspondence between, say the class name lz.view
and the tag name <view>
. (Notice in lz.view the mixed case, and the absence of the period between lz and the tag name.) Also there was a distinction between LFC classes and user-created classes. The new lz.foo form is consistent across LFC classes and user-created classes. The old forms will still work, and they appear throughout this documentation and in example code. At some point, however, the old forms will probably be deprecated, and it would be a good practice to adopt the new form in your code.
Let's start by making a distinction between what is syntactically allowable and what is meaningful.
Remember that all LZX programs are well-formed XML files. That means that all portions of the program, including embedded JavaScript, must conform to XML rules. Therefore where JavaScript uses characters that are meaningful to XML, such as the left angle bracket <, you must make sure that those characters don't confuse the XML parser. You can do that in either of two ways:
This is the sum total of rules for making sure that XML does not trip on JavaScript.
Although the admixture of two different sets of language rules in one language does create opportunities for confusion, it's fairly easy to recognize how LZX programs are structured, and what kind of code goes where. There are only a few contexts in which script code can appear in LZX programs. After you learn to recognize these contexts you are unlikely to be confused about what syntax applies. JavaScript is used:
-
between an opening and closing
<script>
and</script>
tag; -
between an opening and closing
<method>
and</method>
tag; -
between an opening and closing
<handler>
and</handler>
tag; -
with the double-quoted right hand value of an assignment statement within certain tags, such as
oninit="
.script expression
"
As we said earlier, most things that you can do in LZX can be done either with XML tags or JavaScript APIs, and mastering LZX requires developing a subtle understanding of how and when to use each. You will find, in general, that tags are best for computations that can be done at compile-time — such as laying out the canvas — and script is best for run-time things, such as responding to user input. But in order for you to make any use of that information you need to understand what is done at compile time and what is done at run time, and much of that is under your control, and dependent on the problem you're trying to solve.
In other words, there is no simple set of unambiguous rules that tell you when to use tags versus when to use script. But there are, however, design patterns common to all well-made LZX programs.
Remember, LZX is primarily a language for manipulating visual objects called views. So the question of when to use tags versus script is usually asked in the context of the creation of views and manipulation of their attributes. Script can be used for other things, such as global functions, but in those instances the need to write procedural code (i.e., script) is usually clear-cut. The finesse part has to do with manipulating views and their attributes.
For example, a simple two-word constraint might express a relationship between views that would require thirty lines of code to express. Most of the time the constraint is the better programming solution. But not always.
Although there are no absolutes, there are some general principles that define best practice in LZX development:
-
Use tags when that is the only option.
-
Use JavaScript when that is the only option.
-
If something can be done with either tags or script, use tags (unless there is a good reason not to).
Each of these principles is described briefly below.
There are certain tags that perform functions that cannot be done using script. For example, the root node (and enclosing tag) of every LZX program is <canvas>
. Every LZX program begins with <canvas>
and ends with </canvas>
; there is no alternative structure using script. Similarly there are no script equivalents for <splash>
, <method>
, <attribute>
, <resource>
, <font>
, and several other tags. Moreover, within certain tag definitions there are certain attributes that can only be set in the tag.
There are several JavaScript APIs that perform functions that cannot be done using tags. For example, LzDelegate, lz.event, LzParam
and similar APIs perform operations that cannot be done using tags. Similarly, there are certain attributes of objects that can only be referenced by script, even for objects that were created with tags. For example, consider
<view name="franklin">
There is an attribute, franklin.subviews,
that can be accessed by script; it is not possible to set or access that attribute in a tag.
In the large number of cases where it is possible to do something using either tags or views, it is generally better to use tags. For example you can create a new view called "sam" using tags
<view name="sam">
or script
sam = new lz.view();
When you use the tag syntax you can quite naturally create hierarchies of nested subviews, define attributes as constraints, and lay out your code in a way that helps you conceptualize the placement of views on the canvas. Achieving any of these results in pure JavaScript would be a colossal pain and negate much of the benefit of the language. Learning to think in LZX means learning to think in terms of views that act nearly autonomously according to the constraints you establish at their creation.
Sometimes it's better to write procedural code instead of declarative code. This may become necessary, for example, to achieve optimal performance: multiply-constrained systems can sometimes become CPU bound. Other times procedural code may make your program's behavior easier to understand: complex rule-based view systems sometimes become inscrutable.
发表评论
-
Red5安装和配置
2011-02-24 10:23 4048Red5安装和配置参考网页:http://www.cahblo ... -
基于Moodle平台的网站调查报告
2011-02-24 10:18 2576基于Moodle平台的网站调查报告 网站举例: ² 西南 ... -
moodle插件模块功能汇总
2011-02-24 10:03 5013Moodle官方提供654种插件或者模块moodle.org ... -
moodle 一体包安装手册(window)
2011-02-24 09:55 1285见附件 -
moodle中上传文件大小控制
2011-02-24 09:51 1842第一步:修改在php4下POST文件大小的限制1.编修php. ... -
linux下面安装moodle
2011-02-24 09:50 20851. 安装moodle运行 ... -
OpenMeetings安装文档
2011-02-15 11:09 2602OpenMeetings 是一个多语言可定制的视频会议和协作系 ... -
Compilation and Execution (openlaszlo)
2010-11-22 11:02 10507. Compilation and Exe ... -
Data Access, Manipulation, and Binding (openlaszlo)
2010-11-22 10:33 11975. Data Access, Manipu ... -
Constraints(openlaszlo)
2010-11-22 10:18 1126constraint 表示可变的变量赋值形式 In LZX, ... -
Events and Methods (openlaszlo)
2010-11-22 09:35 13743. Events,Methods ,han ... -
Dimdim&Moodle安装配置文档节选
2010-11-09 17:40 2551Dimdim&Moodle安装配置文档节选 ... -
Red5如何响应rmpt的请求,中间涉及哪些关键类?
2010-11-01 15:35 1544Red5如何响应rmpt的请求,中间涉及哪些关键类? 响应请 ... -
red5的eclipse插件和用法
2010-10-30 20:56 1141参见http://www.red5.org/wiki/Red5 ... -
red5集群分析
2010-10-28 19:42 50301. 边(Edge ): 1. 边的主要作用是管理连接,并可以 ... -
red5源代码分析
2010-10-26 08:59 3869Red5如何响应rmpt的请求 ... -
创建第一个red5程序
2010-10-25 15:33 21491.下载最新版本的RED5 http://osflash.or ... -
openlaszlo中多媒体组件介绍
2010-10-14 15:50 1130在openlaszlo中我们可以处理图像,音视频等媒体文件。详 ... -
openlaszlo组件的简单介绍
2010-10-14 15:50 1293openlaszlo组件的简单介绍 收藏 在写laszlo ... -
创建一个简单的openlaszlo程序
2010-10-14 15:49 1072前面说到过openlaszlo程序是一组xml格式和javas ...
相关推荐
### 结合滤波与统计方法实现异常检测 #### 摘要 本文介绍了一种针对大规模网络(如企业或互联网服务提供商(ISP)网络)进行异常检测的方法。研究重点是整个网络流量状态的宏观视图——即所谓的流量矩阵。...
本文的标题《Combining Explicit and Implicit Feature Interactions for Recommender Systems.pdf》和描述表明,文章主题聚焦于推荐系统领域,并且探讨了如何结合显式和隐式的特征交互。这方面的研究对于理解和改善...
Combine Sketch and Tone for Pencil Drawing Production 在计算机图形学和计算机视觉领域中,生成铅笔画是一项具有挑战性的任务。 Lu C, Xu L, Jia J 在他们的论文中提出了一个基于 sketch 和 tone 的方法来生成...
除了理论上的方法外,《Combining Pattern Classifiers Methods and Algorithms》还可能涉及这些组合模式分类器算法的优化与实现。这包括算法效率的提升、减少计算复杂度、避免过拟合等实际问题。书中可能会探讨如何...
With this book, a stellar author team covers the new controls in the AJAX toolbox, the back button history, and script combining, and they also examine the new capabilities of WCF including changes ...
Lucas/Kanade Meets Horn/Schunck: Combining Local and Global Optic Flow Methods Lucas/Kanade 与 Horn/Schunck: 局部与全局光流方法的结合
By uniquely combining current concepts and practical applications in computer graphics, four well-known authors provide here the most comprehensive, authoritative, and up-to-date coverage of the ...
### 结合阴影检测与模拟以估计车辆大小及位置 #### 概述 本文提出了一种结合阴影检测技术和三维盒模型(包括阴影模拟)的方法来准确估计道路上车辆的大小和位置。这种方法通过比较真实图像中的背景、前景和阴影...
Sabourdy, combining various implicit surfaces with soft blending capacities in a CSG tree. This extension allows integration of plane surfaces, skeletons and many other types of implicit surfaces. It ...
3,how to use matlab functions in c++ through comtool and other means, such as matcom.4,the api reference for matlab.you might find this document in matlab help directory. hoWEVER,it's useful to put it...
### 结合相关性和干扰方法研究人脑中的皮层交互作用 #### 编辑焦点:结合相关性和干扰方法在人脑中的应用 近年来,人类对于大脑注意力机制的理解与测量取得了显著进展。通过研究发现,注意力分配时头皮上可以记录...
论文"Combining EfficientNet and Vision Transformers for Video Deepfake Detection"由Davide Coccomini等人撰写,探讨了如何将EfficientNet与视觉变换器结合起来,以提高视频深伪检测的性能。EfficientNet是一种...
### 基于结合分割与阴影的空中图像建筑识别技术 #### 概述 本文介绍了一种用于处理高分辨率空中图像的新型建筑检测算法。该算法利用建筑物与其阴影之间的几何关系,通过光照模型来实现更加通用的建筑检测,即使面对...
在网络信息管理领域,敏感信息过滤是一项重要的技术,它旨在识别和阻止网络上的有害内容传播,特别是色情、暴力等非法信息。这些有害内容对社会和年轻人尤其有严重的负面影响,因此,研究者们对于如何有效过滤网络...
- If customer decide to migrate to HP-UX platform, it’s homogeneous system migration, HP suggest combining migration and upgrade in one step. - If customer decide to migration to Windows platform, it...
12.2 A Framework for Combining Multiple Recognizers 12.3 Voting Schemes 12.4 The Confusion Matrix 12.5 Reliability 12.6 Some Empirical Approaches References and Bibliography Index