gpt4 book ai didi

grails - 在grails中获取错误 “No signature of method is applicable for argument types: (com.vproc.market.SubCategory)”

转载 作者:行者123 更新时间:2023-12-02 15:09:05 26 4
gpt4 key购买 nike

我正在尝试将类别和子类别添加到组织(当前已登录用户)。我可以添加类别,但是无法向组织添加子类别。当我尝试时,收到以下消息:

No signature of method: com.vproc.market.Follower.addToSubCategories() is applicable for argument types: (com.vproc.market.SubCategory) values: [com.vproc.market.SubCategory : 4]. 

我尝试按照下面的“组织 Controller ”方法将类别和子类别添加到组织。

OrganizationController.groovy
   def follow() {
Subscriber loggedinSubscriber = subscriberService.getLoggedinSubscriber()
Party organization = loggedinSubscriber?.customer?.party
def marketInstance = Category.get(params.abc)
def follower = new Follower()
follower.followedBy = organization
follower.category = marketInstance
def sub = params.list('subcategories')
sub.each { id ->
follower.addToSubCategories(SubCategory.get(id))
}
follower.save(failOnError: true);
flash.msg = "Okay. This market is now on your watchlist."
redirect (action: "profile")
}

在这种方法中,我在以下行中出错:
follower.addToSubCategories(SubCategory.get(id))

在问题标题中提到。

Organization.groovy
package com.vproc.member

import java.util.Date;
import com.vproc.market.SubCategory;

class Organization extends Party{

String orgName
Person contact
String orgSize
boolean isVendor = false

static hasMany = [follows: SubCategory]

static constraints = {
orgName blank: false
orgSize blank: false
}
}

Follower.groovy
package com.vproc.market
import com.vproc.member.Organization;

class Follower {

Category category
Organization followedBy
SubCategory subCategory
static constraints = {
}
}

关注者是将类别和子类别添加到组织中并进行存储的域。

Category.groovy
package com.vproc.market

import com.vproc.enquiry.Enquiry;

class Category {

String name
String description
static constraints = {
}
static hasMany = [ subCategories: SubCategory ]
}

SubCategory.groovy
package com.vproc.market

import com.vproc.enquiry.Enquiry;

class SubCategory {
String name

static hasMany = [requirements: Enquiry]
static belongsTo = [ category: Category]
static constraints = {
requirements nullable:true
}
}

gsp文件
<g:form  controller="organization" params="[temp : marketInstance?.id]" action="follow" method="post">
<g:hiddenField name= "abc" value="${marketInstance?.id}" />
<g:hiddenField name="id" value="${subcategory?.id}" />
<div style="margin-left:200px">
<input type="button" class="button-inner" id="check1" value="Check All" />
<input type="hidden" id="isChkd" value="true" />
<g:each var="subcategory" in="${subCategroyInstanceList}">
<div>
<g:checkBox class="cb1-element" name="subcategories" value="${subcategory.id}"/>
<label for="subcategories"> ${subcategory.name}</label>
</div>
</g:each>
<button class="btn btn-inverse">Submit</button>
</div>
</g:form>

摘要:我想向组织添加类别和子类别。我可以成功添加类别,但无法将子类别添加到组织中。

在以下各行中发生错误:
def sub = params.list('subcategories')
sub.each { id ->
follower.addToSubCategories(SubCategory.get(id))
}

方法的无签名:com.vproc.market.Follower.addToSubCategories()适用于参数类型:

最佳答案

只需快速查看您的域,“关注者”域就与SubCategory有直接关联。您可以简单地将subCategoty分配给不需要follower.addToSubCategories(SubCategory.get(id))
可能是这样的:

follower.subCategory = SubCategory.get(id)

关于grails - 在grails中获取错误 “No signature of method is applicable for argument types: (com.vproc.market.SubCategory)”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19790241/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com