私は非常に新しいgrailsです。私がしたいことは、enumクラスからselect(コンボボックス)にデータ要素をロードしてタグライブラリを作成することですそれのための。grailsのselect(combobox)用のタグライブラリの使い方と作成方法
タグライブラリクラス
package feedback
import imocha.project.Feedback
import imocha.project.FeedbackType
class FeedbackTagLib {
static namespace = "l"
def enumFeedbackType ={attrs, body ->
attrs.name = "type"
attrs.from = "${FeedbackType.values()}"
out << g.select(attrs.name, attrs.from, attrs.value, attrs.optionKey)
}
}
のEnumクラス
public enum FeedbackType {
CLA('Complaint'),
CLE('Complement'),
ENQ('Enquiry')
final String value
FeedbackType(String value){ this.value = value }
@Override
String toString(){ value }
String getKey() { name() }
}
私は、これはエラー
URI /feedback/feedback/create
Class groovy.lang.MissingMethodException
Message No signature of method: org.codehaus.groovy.grails.web.pages.GroovyPage.select() is applicable for argument types: (java.lang.String, org.codehaus.groovy.runtime.GStringImpl, null, null) values: [type, [Complaint, Complement, Enquiry], null, null] Possible solutions: collect(), getOut(), inspect(), every()
あるこの
<l:enumFeedbackType value="${feedbackInstance?.type}" optionKey ="key" />
でGSPのタグライブラリと呼ばれます
を、あなたの列挙型 – injecteer
ためのimport文が欠落しているが、それはグルーヴィーのsrc /の下にあります!私がインポートをしているのなら、これはimport src.groovy.FeedbackTypeのようなものですか?これはコンパイラによって受け入れられません –
デフォルト以外のパッケージのクラスにデフォルトのパッケージクラスをインポートすることはできません。ですから、あなたのタグライブラリをデフォルトのパッケージに入れるか、または 'feedback 'に列挙してください – injecteer