Mryqu's Notes


  • 首页

  • 搜索
close

[OpenUI5] 数据绑定模式

时间: 2015-02-02   |   分类: FrontEnd     |   阅读: 44 字 ~1分钟
OpenUI5数据绑定模式概念 OpenUI5开发指南-数据绑定模式介绍了OpenUI5数据绑定模式概念和不同模型的默认值。 绑定模式 绑定模式定义了数据源如何绑定。不同模型实现需要特定绑定模式。例如资源模型仅支持模型到视图的一次性绑定。 SAPUI5提供如下绑定模式: 单向绑定:单向绑定意味着模型到视图的绑定;模型中的数据变化将更新相应的绑定和视图。 双向绑定:双向绑定意味着模型到视图及视图到模型的绑定;模型/视图中的数据变化将更新相应的绑定和视图/模型。 一次性绑定:一次性绑定意味着模型到视图的绑定。 下表展示了不同模型分别支持的绑定模式: |模型|一次性绑定|双向绑定|单向绑定 |—– |资源模型|–|–|X |JSON模型|X|X|X |XML模型|X|X|X |OData模型|X|X|X 资源模型仅处理静态文本,所以仅支持一次性绑定模式 模型的默认绑定模式 当模型实例被创建后,该实例具有一个默认绑定模式。该模型实例的所有绑定会采用他们自己默认绑定模式。 下表展示了不同模式实现的默认绑定模式。 |模型|默认绑定模式 |—– |资源模型|一次性绑定 |JSON模型|双向绑定 |XML模型|双向绑定 |OData模型|单向绑定 OpenUI5数据绑定模式范例 OpenUI5开发指南-数据绑定入门介绍了数据绑定使用范例。 OpenUI5数据绑定模式源代码研究 数据绑定模式在sap.ui.model.BindingMode中定义。 通过如上类图可知,JSON模型类和XML模型类继承自客户端模型类,资源模型和OData模型直接继承自模型类。 客户端模型具有额外的setData方法。客户端模型相对模型类多了一层客户端数据,可以存储视图属性变化相应的数据,应此能够在不跟服务器端交互的情况下实现双向绑定。网上的很多演示采用客户端模型,就是因为无需搭建服务器,易于实现。 模型类原型有一个checkUpdate方法,用于在模型数据发生变化后,检查模型的所有绑定是否需要更新以实现模型到视图的绑定。其调用情况如下: JSON模型和XML模型:被setData和setProperty方法调用 OData模型:被loadData、setProperty和refresh方法调用 资源模型:无调用 视图到模型的绑定,主要在sap.ui.base.ManagedObject类实现。 ManagedObject是所有视图控件的祖宗类,ManagedObject原型的_bindProperty方法判别绑定模式是否是一次性绑定,是的话就将绑定上的事件和模型数据变化处理程序卸载掉。 ManagedObject原型的updateModelProperty方法判别绑定模式是否是双向绑定,是的话就将视图属性变化写入绑定,从而将数据写入模型。 参考 OpenUI5 API参考指南 sap.ui.model包源代码 - GitHub

[Hadoop] YARN中的AuxiliaryService

时间: 2015-02-01   |   分类: BigData     |   阅读: 76 字 ~1分钟
一个附属服务(AuxiliaryService)是由YARN中节点管理器(NM)启动的通用服务。该服务由YARN配置“yarn.nodemanager.aux-services”定义。默认值为mapreduce_shuffle,即MRv2中的ShuffleHandler。 AuxiliaryService是节点管理器内的服务,接收应用/容器初始化和停止事件并作相应处理。 MRv2提供了一个叫做org.apache.hadoop.mapred.ShuffleHandler的内建AuxiliaryService,用于将节点内map输出文件提供给reducer(上图中除ShuffleHandler之外的其他AuxiliaryService子类均为测试类)。 节点管理器可能有多个AuxiliaryService,类AuxServices用于处理此类服务集合。 当AuxServices对象启动,它从YarnConfiguration.NM_AUX_SERVICES(即"yarn.nodemanager.aux-services")获得附属服务名,从YarnConfiguration.NM_AUX_SERVICE_FMT(即"yarn.nodemanager.aux-services.%s.class")获得对应的服务类名。例如"yarn.nodemanager.aux-services.mapreduce_shuffle.class"对应ShuffleHandler类。之后它将服务置入serviceMap并调用init()方法对服务进行初始化。 Hadoop实现是一个事件驱动系统。AuxServices既是ServiceStateChangeListener也是EventHandler,用于处理AuxServicesEventType事件。 public enum AuxServicesEventType { APPLICATION_INIT, APPLICATION_STOP, CONTAINER_INIT, CONTAINER_STOP } public class AuxServicesEvent extends AbstractEvent { private final String user; private final String serviceId; private final ByteBuffer serviceData; private final ApplicationId appId; private final Container container; } public abstract class AbstractEvent> implements Event { private final TYPE type; private final long timestamp; } 在handle(AuxServicesEventevent)方法中,每个事件与AuxiliaryService中的一个API调用相关连。例如,只要AuxServices收到一个APPLICATION_INIT事件,对应AuxiliaryService的initializeApplication()方法就会被调用。 那一个事件如何被传递给AuxServices的? NodeManager类包含一个ContainerManagerImpl对象变量,而ContainerManagerImpl类包含一个AuxServices对象变量。此外ContainerManagerImpl类有自己的AsyncDispatcher,它会向AuxServices分发所有AuxServicesEventType类型事件。 AuxServicesEventType.APPLICATION_STOP事件在ApplicationImpl类中被创建,节点管理器中应用表述的状态机触发。 其他三个的AuxServicesEventType事件,例如APPLICATION_INIT、CONTAINER_INIT和CONTAINER_STOP,在ContainerImpl类中随着容器的生命周期被创建。 参考 AuxiliaryService in Hadoop 2 Implementing a Custom Shuffle and a Custom Sort

[JavaScript] Open/SaveAs File

时间: 2015-01-31   |   分类: FrontEnd     |   阅读: 36 字 ~1分钟
看了一下HTML5应用中如何打开文件或另存文件。与Swing/EclipseRCP应用不同,有些操作由于安全的原因无法在HTML5应用内使用,而是浏览器与客户交互。例如HTML5应用往本地写文件。下面的显示了在新窗口打开文件、在当前窗口打开文件以及a标签的download属性。 学习了下面链接中的代码和文章,其中FileSaver.js是一个跨浏览器的JS库,但是在各个浏览器上保存文件的用户体验却不相同。目前为止,我还没发现更好的跨浏览器/设备的另存文件解决方案。 Google HTML5 Download Demo An HTML5 saveAs() FileSaver implementation New HTML5 Attributes for Hyperlinks: download, media, and ping Save files on disk using JavaScript or JQuery! JavaScript Question:Opening Save As Dialog Internet media type

[Git] Create patch with untracked files

时间: 2015-01-27   |   分类: Tool   Git     |   阅读: 19 字 ~1分钟
前一博文Create patch with untracked files using Git format-patch/diff/stash中的方案比较绕,今天有了一个更好一点的法子: git add . git diff --cached > yqu.patch git reset origin/master

[Git] Create patch with untracked files using Git format-patch/diff/stash

时间: 2015-01-26   |   分类: Tool   Git     |   阅读: 205 字 ~1分钟
Setup testing environment I created 123.txt at branch master, then modified 123.txt and added321.txt at branch yqu C:\test>mkdir GitTest C:\test>cd GitTest C:\test\GitTest>git init Initialized empty Git repository in C:/test/GitTest/.git/ C:\test\GitTest>echo "this is a file at mast branch" > 123.txt C:\test\GitTest>git add 123.txt C:\test\GitTest>git commit -m "initial commit" [master (root-commit) f140825] initial commit 1 file changed, 1 insertion(+) create mode 100644 123.txt C:\test\GitTest>git push origin HEAD:master C:\test\GitTest>git checkout -b yqu Switched to a new branch 'yqu' C:\test\GitTest>echo "bye" >> 123.
阅读全文 »

[C] 了解printf中的%.s

时间: 2015-01-22   |   分类: C++     |   阅读: 258 字 ~2分钟
偶尔看到C代码printf("%.*s",dataL,data);,对printf中的格式化字符串"%.*s"有点不解。 查看了http://www.cplusplus.com/reference/cstdio/printf/文档后,有所理解。 | width |description |—– | (number) |Minimum number of characters to be printed. If the value tobe printed is shorter than this number, the result is padded withblank spaces. The value is not truncated even if the result islarger. | * |The width is not specified in the format string, but as an additional integer value argument preceding theargument that has to be formatted. | .precision |description |—– | .
阅读全文 »

WebDAV Javascript库

时间: 2015-01-20   |   分类: FrontEnd     |   阅读: 12 字 ~1分钟
需要用JS库对WebDAV进行CRUD操作,找了一堆备选JS库。 IT Hit WebDAV Ajax Library:http://www.webdavsystem.com/ajax/programming https://github.com/sandro-pasquali/jquery.dav https://github.com/evert/davclient.js https://github.com/matthewp/webdav https://github.com/aslakhellesoy/webdavjs https://github.com/dom111/webdav-js https://github.com/sara-nl/js-webdav-client

Spring3 REST can't solve list of object generated by Javascript

时间: 2015-01-16   |   分类: Service+JavaEE   Spring     |   阅读: 160 字 ~1分钟
最近遭遇Spring3REST无法解析对象数组这么一个问题。为了排除客户端Javascript代码嫌疑,我通过GET操作从Spring RestfulWeb服务获取一个复杂对象,然后通过POST操作将其原封不动返给Spring Restful Web服务,问题依旧重现。 客户端代码 var meatadata='[{"varName":"id","varTitle":"The Id","varIndex":1},{"varName":"name","varTitle":"The Name","varIndex":2},{"varName":"age","varTitle":"The Age","varIndex":3}]'; $.ajax({ url: "configure", type: "POST", data: metadata, dataType: "json", contentType: "application/json", success: function (res) { $('#cfgContent').text(JSON.stringify(res)); $('#cfgError').text(""); }, error: function (res) { $('#cfgContent').text(""); $('#cfgError').text(res.responseText); } }); 中间层代码 package com.yqu.rest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import java.util.ArrayList; import java.util.List; @RestController public class ConfigurationController { @RequestMapping(value = "/", method = RequestMethod.GET) public ModelAndView home(Model m){ System.out.println("home"); return new ModelAndView("index"); } @RequestMapping(value = "/configure", method = RequestMethod.
阅读全文 »

Spring REST can't solve nested object array generated by JavaScript

时间: 2015-01-15   |   分类: Service+JavaEE   Spring     |   阅读: 506 字 ~3分钟
最近遭遇SpringREST无法解析嵌套对象数组这么一个问题。为了排除客户端Javascript代码嫌疑,我通过GET操作从Spring RestfulWeb服务获取一个复杂对象,然后通过POST操作将其原封不动返给Spring Restful Web服务,问题依旧重现。 所操作的复杂对象 客户端POST响应 中间层代码 package com.yqu.rest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; import java.util.ArrayList; import java.util.List; @RestController public class ConfigurationController { @RequestMapping(value = "/", method = RequestMethod.GET) public ModelAndView home(Model m){ System.out.println("home"); return new ModelAndView("index"); } @RequestMapping(value = "/configure", method = RequestMethod.GET) public @ResponseBody SheetVO getConfiguration() { List columns = new ArrayList(); columns.add(new ColumnVO("id","The Id",1)); columns.add(new ColumnVO("name","The Name",2)); columns.add(new ColumnVO("age","The Age",3)); SheetVO metadata = new SheetVO(SheetVO.
阅读全文 »

[OpenUI5] 示例: open dialog which content is a form defined in another view

时间: 2015-01-11   |   分类: FrontEnd     |   阅读: 5 字 ~1分钟
使用OpenUI5做了一个例子,在一个JSVIEW中定义的dialog的内容是另外一个JSVIEW中定义的form。 示例位置: http://jsbin.com/fotepu/1/edit?html,output 此外,通过学习http://stackoverflow.com/questions/25510090/sapui5-attach-chart-to-dialog ,了解到dialog内容为图表时有可能需要使用invalidate()函数。
35 36 37 38 39 40 41 42 43

Programmer & Architect

662 日志
27 分类
1472 标签
RSS 订阅
GitHub Twitter FB Page
© 2009 - 2023 Mryqu's Notes
Powered by - Hugo v0.120.4
Theme by - NexT
0%