首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Jspresso用户界面上没有处理的N-N双向关系

在Jspresso用户界面上没有处理的N-N双向关系
EN

Stack Overflow用户
提问于 2015-10-05 08:22:03
回答 1查看 66关注 0票数 0

我正在研究Jspresso框架(用Swing启动项目)。我在组件之间建立了not双向关系,但是与这些关系相对应的字段没有出现。例如,我有一个项目和学生之间的关系(一个学生可以有很多项目,一个项目可以有很多学生)。当我添加一个项目并在它的详细视图中打开它时,我可以创建一个新的学生并将它添加到项目中,但是我不能将一个现有的学生添加到该项目中,也不能根据其搜索视图中的学生搜索一个项目。有办法展示这个吗?

这是我的view.groovy

代码语言:javascript
运行
复制
 // Implement your views here using the SJS DSL.

 form('Project.pane',
    parent:'decoratedView',
    labelsPosition:'ASIDE',
    columnCount:2,
    fields:     ['name','students','technologies','usesTrainers','technicalTrainers']){
    actionMap{
            actionList('FILE'){
                action(ref:'saveModuleObjectFrontAction')
                action(ref:'reloadModuleObjectFrontAction')
          }
    }
}

table'Project-students.table',
    parent:'decoratedView',
    actionMap:'masterDetailActionMap'

split_vertical'Project.proj.view',
    model:'Project',
    top:'Project.pane',
    bottom:'Project-students.table'



form('Student.pane',
    parent:'decoratedView',
    labelsPosition:'ASIDE',
    columnCount:2){
        actionMap{
                actionList('FILE'){
                action(ref:'saveModuleObjectFrontAction')
                action(ref:'reloadModuleObjectFrontAction')
          }
    }
}

table'Student-technologies.table',
    parent:'decoratedView',
    actionMap:'masterDetailActionMap'

split_vertical'Student.proj.view',
    model:'Student',
    top:'Student.pane',
    bottom:'Student-technologies.table'

form('Trainer.pane',
    parent:'decoratedView',
    labelsPosition:'ASIDE',
    columnCount:5)

form('Technology.pane',
    parent:'decoratedView',
    labelsPosition:'ASIDE',
    columnCount:5)

这是我的model.groovy

代码语言:javascript
运行
复制
// Implement your domain here using the SJS DSL.

Interface('Traceable',
interceptors: 'TraceableLifecycleInterceptor',
uncloned: ['createTimestamp',
           'lastUpdateTimestamp','lastUpdatedBy','createdBy']) {
  string_64 'createdBy',readOnly:true
  date_time 'createTimestamp', timeZoneAware: true, readOnly: true
  string_64 'lastUpdatedBy', readOnly:true
  date_time 'lastUpdateTimestamp', timeZoneAware: true, readOnly: true
}

Entity ('Project', extend:'Traceable',toString:'name',
icon:'project.png',
rendered: ['name','lastUpdateTimestamp','lastUpdatedBy','createTimestamp','createdBy'],
queryable: ['name']){
string_64 'name'
set 'technologies', composition:true, ref:'Technology'
set 'technicalTrainers', composition:true, ref:'Trainer'
set 'usesTrainers', composition:true, ref:'Trainer'
set 'students', composition:true, ref:'Student'

}

Entity ('Technology', extend:'Traceable',toString:'name',
icon:'technology.png',
rendered: ['name','lastUpdateTimestamp','lastUpdatedBy','createTimestamp','createdBy'],
queryable: ['name']){
string_64 'name'
set 'projects', ref:'Project', reverse:'Project-technologies'
set 'studentsAbleToUseIt', ref:'Technology', reverse:'Student-technologies'
set 'trainersAbleToTeachIt', ref:'Technology', reverse:'Trainer-technologies'
}

Interface ('Person', extend:'Traceable'){
string_64 'lastname'
string_64 'firstname'
date_time 'createTimestamp', timeZoneAware: true, readOnly: true
date_time 'lastUpdateTimestamp', timeZoneAware: true, readOnly: true
}

 Entity ('Trainer',
    extend: 'Person', 
    toString:'firstname',
    icon:'trainer.png',
    rendered: ['firstname','lastname','lastUpdateTimestamp','lastUpdatedBy','createTimestamp','createdBy'],
    queryable: ['firstname','lastname']){
set 'projectsAsTechnicalTrainer', ref:'Project', reverse:'Project-technicalTrainers'
set 'projectsAsUsesTrainer', ref:'Project', reverse:'Project-usesTrainers'
set 'technologies', composition:true, ref:'Technology'
date_time 'createTimestamp', timeZoneAware: true, readOnly: true
date_time 'lastUpdateTimestamp', timeZoneAware: true, readOnly: true
}

Entity ('Student',
    extend: 'Person', 
    toString:'firstname',
    icon:'student.png',
    rendered: ['firstname','lastname','lastUpdateTimestamp','lastUpdatedBy','createTimestamp','createdBy'],
    queryable: ['firstname','lastname']){
set 'technologies', composition:true, ref:'Technology'
set 'projects', ref:'Project', reverse:'Project-students'
date_time 'createTimestamp', timeZoneAware: true, readOnly: true
date_time 'lastUpdateTimestamp', timeZoneAware: true, readOnly: true
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-23 17:15:40

你绝对可以很容易地实现这两个目标。

1/ A N-N关系可以简单地看作是两种1-N关系。因此,您可以在面向Project-students的视图上使用Project关系,在面向学生的视图上使用Student-projects。您可以使用两个不同的过滤器模块(一个在Project上,一个在Student上),或者补充您的Project.proj.view,以便通过添加一个额外的表来添加第二级细节,该表将在第一个表详细信息中显示所选学生的Student-projects

类似于:

代码语言:javascript
运行
复制
split_vertical ('Project.proj.view',
  model:'Project',
  top:'Project.pane') {
  bottom {
    split_horizontal(
      left:  'Project-students.table',
      right: 'Student-projects.table',
      cascadingModels: true
    )
  }
}

2/关于选择并将现有的ProjectStudent添加到各自集合的能力,您可以使用自定义的LOV操作,如Jspresso-CE参考文档第1章中所解释的那样。

类似于:

代码语言:javascript
运行
复制
table('Project-students.table') {
  actionMap {
    actionList('EDIT'){
      action(parent:'lovAction',
        custom:[
          autoquery:false,
          entityDescriptor_ref:'Student',
          okAction_ref:'addAnyToMasterFrontAction'
        ]
      )
      action(ref:'removeAnyCollectionFromMasterFrontAction')
    }
  }
}

3.对于通过Project (或反向)过滤Student,Jspresso支持将集合属性定义为filter属性。在这种情况下,filter视图将为学生安装一个LOV来过滤项目。

如果希望默认情况下在每个Project视图上使用它,请直接在模型上声明它。

类似于:

代码语言:javascript
运行
复制
Entity ('Project'
        ...
        queryable : ['name', 'students']
        ...){
  ...
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32944084

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档