小编Bur*_*ith的帖子

在重定向中呈现命令验证错误

我无法从命令对象中呈现错误.它做得很好,但我的.gsp视图不会渲染我提出的错误.

这是我的控制器动作:

def handleModifyProfile2 = { CreditProviderModificationCommand cpmc -> // bind params to the command object
   if (cpmc.hasErrors()) {
      flash.message = "Error modifying your profile:"
      redirect(action: "modifyProfile", params: [creditProvider : cpmc])
   } ...
Run Code Online (Sandbox Code Playgroud)

以下是我尝试在.gsp视图中呈现错误的方法:

<g:hasErrors bean="${creditProvider}">
   <div class="errors">
       <g:renderErrors bean="${creditProvider}" as="list" />
   </div>
</g:hasErrors>
Run Code Online (Sandbox Code Playgroud)

如何才能在视图中显示错误?

error-handling grails render grails-validation grails-constraints

7
推荐指数
1
解决办法
3659
查看次数

使用Grails时,我是否应该关心Open View in View?

根据我将spring MVC与hibernate结合使用的经验,我知道在渲染视图时寻址到lazy-fetched集合时发生的惰性异常问题.它通过引入OpenSessionInViewInterceptorOpenSessionInViewFilter因此为每个请求启用一个hibernate会话来修复纯粹的spring + hibernate世界.

所以问题是:我是否应该关心grails中的这个问题,或者默认情况下启用这样的一个会话每个请求的行为.

如果这不是grails默认值,请提供一些代码来实现此行为.

谢谢.

model-view-controller session grails spring

6
推荐指数
1
解决办法
1464
查看次数

drools drl怎么没条件

我试图用drools drl语言编写一个规则,我想做类似的事情!(A && B)但它似乎不喜欢!操作员或不是.我很难找到关于流口水的好文档

请参阅以下示例代码:

  rule "Test Rule"
   when
      testBean : testBean(!(testList contains "test"  && testList2 contains "test2"))
   then
      testBean.setText( "This is a test" );
   end
Run Code Online (Sandbox Code Playgroud)

我要感谢任何人都能给我的任何帮助

提前致谢

drools business-rules

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

将SpringSecurityService注入Grails中的Filter时为空

我正在尝试在过滤器中使用SpringSecurityService来获取当前登录的用户.问题是我得到了null并且无法获得当前用户.

class ApplicationFilters {

   def springSecurityService

   def filters = {
      all(controller:'*', action:'*') {

         after = { Map model ->

            def userName=springSecurityService.currentUser
         }
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

我也尝试从过滤器获取params地图,我也得到了null.我该怎么做才能解决这个问题?

谢谢,

grails

6
推荐指数
1
解决办法
809
查看次数

Grails"无法设置只读属性:programId"

我被扔进了一个现有的grails项目,我遇到的一个问题是,当保存一些批处理时,我得到错误: Cannot set readonly property: programId

这是导致错误的保存代码段

// Create a batch
def batch = new Batch()
batch.name = session.batch_name
batch.startDate = new Date()
batch.endDate = new Date()
batch.programId = 120
if(batch.save()) {
  ...
}
Run Code Online (Sandbox Code Playgroud)

这是我的批处理域类

class Batch  extends AbstractDomainObject{
    String name
    Date startDate
    Date endDate
    String comments
    StatusType currentStatus

    static belongsTo = [program:Program]    

    static constraints = {
        name(blank:false,maxSize:100)
        startDate()
        endDate()
        comments (nullable:true, maxSize:DEFAULT_SIZE_OF_COMMENTS)
        currentStatus(nullable:true)
    }
    static transients= ["currentStatus"]

    static mapping = {
        id column:'batch_id', generator:'sequence', params:[sequence:'sq_batch']
        currentStatus column:'status_type_id'
        program column:'program_id' …
Run Code Online (Sandbox Code Playgroud)

grails

6
推荐指数
1
解决办法
3468
查看次数

如何使用Grails 2.3.4连接postgres数据库

我是Grails的新手.我正在尝试使用grails 2.3.4连接postgresql 9.0数据库服务器.我已将postgresql-9.0-801.jdbc3.jar文件添加到grails应用程序的lib文件夹中.当我在Intellij编辑器上运行应用程序时,会出现以下错误.哪里我做错了?

|Running Grails application Error | 2013-12-08 18:44:55,837 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool. Message: Driver:org.postgresql.Driver@7c3b99 returned null for URL:jdbc:postgres://localhost/clientpro Line | Method ->> 303 | innerRun in java.util.concurrent.FutureTask$Sync
| 138 | run in java.util.concurrent.FutureTask | 895 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker | 918 | run in '' ^ 662 | run . . in java.lang.Thread Error | 2013-12-08 18:44:55,877 [localhost-startStop-1] ERROR pool.ConnectionPool - Unable to create initial connections of pool. Message: Driver:org.postgresql.Driver@1ab5d6d returned …
Run Code Online (Sandbox Code Playgroud)

postgresql grails

6
推荐指数
1
解决办法
4328
查看次数

将在Google Apps中创建的Google任务与在我们的Web应用程序中创建的任务同步(Grails/Java)

我们希望将Google Tasks API集成到我们的Grails Web应用程序中,但是我对于同步任务和防止数据冲突有很多顾虑.

  1. 在授权Google帐户中创建任务时,同步任务的最佳做法是什么.我们是否应该定期创建一个轮询这些服务的服务,或者我们是否可以通过编程方式在用户的Google帐户中启用某种Push更新,以便通知我们的Web应用程序更改?

  2. 在Google帐户中操作同一任务时,我们如何防止用户在我们的系统中编辑任务时产生的冲突?有没有可用的版本/锁定?

grails sync google-tasks google-tasks-api

6
推荐指数
1
解决办法
208
查看次数

NetBeans中的Grails 3.0支持

我在NetBeans中运行Grails 2.2.0,它工作正常.我尝试将项目升级到Grails 3.0,但在创建项目后,NetBeans无法打开项目.

有谁知道在NetBeans中安装哪些插件(如果可用)以使Grails 3.0工作?

grails netbeans grails-3.0

6
推荐指数
1
解决办法
2786
查看次数

Grails渲染插件的空指针异常

我在使用渲染插件时遇到一些问题.它总是返回一个空指针异常.我看到了严重的类似问题,但我没有找到我错在哪里.

  • 我的模板代码:/views/appRetail/_report.gsp

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org /TR/xhtml1/DTD/xhtml1-strict.dtd">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <title>Welcome to Production !</title>
    </head>
    <html>
       <body>
        REPORT
       </body>
    </html>
    
    Run Code Online (Sandbox Code Playgroud)
  • 我的控制器代码:

    class AppRetailController {
    
      def pdfRenderingService
    
      def renderFormPDF() {
    
        def apps = App.findAll()
        new File("test.pdf").withOutputStream { outputStream ->
            pdfRenderingService.render(template: '/appRetail/report', model: [apps:apps], outputStream)
        }
      }
    }
    
    Run Code Online (Sandbox Code Playgroud)

这是堆栈跟踪:

2015-04-17 10:31:54,552 [http-bio-8080-exec-4] ERROR   errors.GrailsExceptionResolver  - NullPointerException occurred when   processing request: [POST] /toolprod/appRetail/renderFormPDF
Stacktrace follows:
Message: null
Line | …
Run Code Online (Sandbox Code Playgroud)

grails grails-plugin

6
推荐指数
2
解决办法
1046
查看次数

在Grails中使用TrustManager [] trustAllCerts = new TrustManager []

我如何在grails中使用以下代码 -

TrustManager[] trustAllCerts = new TrustManager[]{
                new X509TrustManager() {
                    public X509Certificate[] getAcceptedIssuers() {
                        return null;
                    }

                    public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
                        return;
                    }

                    public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
                        return;
                    }
                }
        };
Run Code Online (Sandbox Code Playgroud)

当我在JAVA项目中运行相同的代码时,上面的代码工作正常,但Grails没有编译代码并给出错误 - 第一行上的数组构造函数调用没有表达式.

groovy

6
推荐指数
1
解决办法
2165
查看次数