小编rom*_*afe的帖子

到initComponent()或不到initComponent()

我在ExtJS 4中构建应用程序时很困难,其中一部分是关于何时在initComponent()中配置某些内容以及何时不...

例如,在Sencha自己的MVC Application Architecture doc中,首次创建网格视图时,他们在initComponent()方法中定义了内联存储.(参见"定义视图"部分)

再往下,当他们将商店分解为一个单独的类时,他们将定义移到了initComponent()之外.有一个有用的评论引起了对这一事实的关注,但没有解释.(请参阅创建模型和存储部分)

我猜原因应该是显而易见的,但我很想念它.有什么指针吗?

extjs extjs4 extjs4.1

45
推荐指数
4
解决办法
4万
查看次数

Gradle将zip压缩为buildDir

我的项目有一个远程依赖项,它实际上只是某些文件的zip,需要在某处解压缩,以便构建可以从文件生成新的java源代码.(我说的一般是关注核心问题而不是具体细节)

我不希望这会如此困难,但我一直无法让它发挥作用.这是我创造的:

我定义了一个新配置:

configurations {
    newConf
}
Run Code Online (Sandbox Code Playgroud)

后来,我为这种混淆定义了一个依赖.它解析为我需要爆炸的zip文件:

dependencies {
    newConf "group:name:version@zip"
}
Run Code Online (Sandbox Code Playgroud)

到目前为止,这些气味对我来说都是正确的,但如果有人不同意,我正在听.

最后,我需要定义一个将zip分解为目录的任务,然后该目录将成为以后代码生成命令的输入.

task explodeModel {
    description = "unzip model into the specified 'modelSrc' directory"

    //input is a "files" collection (usually just one:  the zip)
    //output is the specified modelSrc dir

    File modelSrc = new File("$buildDir/modelSrc")
    outputs.files modelSrc

    doLast {
        configurations.newConf.allArtifacts.each { artifact -> println artifact }
    }

}
Run Code Online (Sandbox Code Playgroud)

显然doLast还没有解压缩任何东西,我只是试图获得zipfile本身的绝对路径,那就是我被卡住的地方.我不知道如何获取文件的路径,以便我可以解压缩它.有帮助吗?

非常感谢

gradle

14
推荐指数
2
解决办法
1万
查看次数

JUnit 4中的非空虚测试方法

我想要一个JUnit 4测试类来实现与其测试类相同的接口.这样,随着接口的改变(我们正在进行早期开发),编译器保证将相应的方法添加到测试类中.例如:

public interface Service {
  public String getFoo();
  public String getBar();
}

public class ServiceImpl implements Service {
  @Override public String getFoo() { return "FOO"; }
  @Override public String getBar() { return "BAR"; }
}

public class ServiceTest implements Service {
  @Override
  @Test
  public String getFoo() {
    //test stuff
  }

  @Override
  @Test
  public String getBar() {
    //test stuff
  }
}
Run Code Online (Sandbox Code Playgroud)

当我尝试这个时,我得到一个错误:"java.lang.Exception:Method getFoo()应该是void",大概是因为测试方法必须返回void.任何人都知道这方面的任何方式?

java junit unit-testing annotations junit4

3
推荐指数
1
解决办法
3336
查看次数

将子组件的配置传递给父组件

通常,要定义网格类型,我会这样做:

Ext.define('MyApp.view.MyGrid', {
  extend: 'Ext.grid.Panel',
  alias: 'widget.myGrid',
  store: 'MyStore',
  columns: [...],
}
Run Code Online (Sandbox Code Playgroud)

然后我通过它的xtype,'myGrid'将它添加到容器或布局中.

我想要做的是定义一个可重用的自定义组件,它可以扩展Ext.grid.Panel或接受相同的配置(例如列),但实际上是一个包含网格和其他东西的容器.

Ext.define('MyApp.components.ContainedGrid', {
  extend: 'Ext.container.Container' //or Ext.grid.Panel, whatever works
  alias: 'widget.containedGrid',
  layout: 'card',
  items: [
    {someObject}, //doesn't matter what this is
    {aGrid}, //the grid that should receive the configs from the caller
  ],
}
Run Code Online (Sandbox Code Playgroud)

理想情况下,此组件可以像常规Ext.grid.Panel对象一样配置,这些配置应该真正应用于items数组中定义的第二个网格.

换句话说,类似下面的内容应该呈现一个包含卡片布局的窗口,其中第二张卡片应该是网格,其中列和商店提供给容器.

Ext.create('Ext.window.Window',  {
  title: 'hi',
  layout: 'fit',
  items: {
    xtype: 'containedGrid',
    store: myStore,
    columns: [...],
  },
});
Run Code Online (Sandbox Code Playgroud)

从逻辑上讲,我只想说提供给容器的配置适用于其中一个组件,但我不知道如何执行它.有什么想法吗?

编辑: 简而言之,我要做的是创建一个像网格一样配置的组件,但实际上是一个包含网格的容器,以及其他一些东西.这个组件将被多次使用,所以我想把它打包成一个可重用的组件.

extjs extjs4

3
推荐指数
1
解决办法
2837
查看次数

标签 统计

extjs ×2

extjs4 ×2

annotations ×1

extjs4.1 ×1

gradle ×1

java ×1

junit ×1

junit4 ×1

unit-testing ×1