2011-09-02 2 views
2

나는 내 html에서 반복적 인 선택 태그를 가지고 있기 때문에 select 속성의 name 속성을 취할 사용자 정의 선택 태그를 만들고 싶습니다. 쉽게) 옵션 태그를 동적으로 생성하는 목록 객체를 제공합니다.playframework - 사용자 정의 선택 태그에 목록 매개 변수 설정하기

는 기본적으로 나는 변수 벡터을하고 컨트롤러에서 전달이

////// custom tag stored in FormSelect.html/////// 
<select name="${_selectName}"> 
    #{list ${_options}, as: 't'} 
     <option value="${t.Description}"> ${t.Description} </option> 
    #{/list} 
</select> 

///////calling the custom tag from another html file////////// 
Type: 
#{FormSelect selectName:'typ', options:types /} 
Region: 
#{FormSelect selectName:'reg', options:regions /} 

유형지역처럼 뭔가를 할 수 있습니다. 나는 내가이 예외를 얻을 위의 코드를 excecute 때 유형지역

의 값을 취할 (# {목록} 내부) select 태그에서 $ {_ 옵션}을 원하는

Template execution error 

Execution error occured in template /app/views/tags/FormSelect.html. Exception raised was MissingMethodException : No signature of method: Template_1002.$() is applicable for argument types: (Template_1002$_run_closure1_closure2) values: [[email protected]] Possible solutions: _(java.lang.String), is(java.lang.Object), run(), run(), any(), get(java.lang.String). 


In /app/views/tags/FormSelect.html (around line 2) 

1: <select name="${_selectName}"> 
2:  #{list ${_options}, as: 't'} 
3:  <option value="${t.Description}"> ${t.Description} </option> 
4:  #{/list} 
5: </select> 

사전에 들으

+0

무엇이 문제입니까? 어떤 오류가 발생합니까? 이 코드를 사용해 보셨습니까? 벡터의 클래스는 무엇입니까? 그들의 코드? –

+0

답장을 보내 주셔서 감사합니다. 필자는 코드를 시험해 보았습니다. 몇 가지 예외가 있습니다. pls는 첫 번째 게시물을 확인합니다. – hari

답변

2

대신

#{list ${_options}, as: 't'} 
     <option value="${t.Description}"> ${t.Description} </option> 
    #{/list} 

사용 :

#{list items:_options, as: 't'} 
     <option value="${t.Description}"> ${t.Description} </option> 
#{/list} 

현재 오류를 해결해야한다.

+0

그것은 예외를 해결했으나 지금은 빈 드롭 다운 상자를 얻었습니다. 목록을 반복합니다. – hari

+0

Sory 내 코드에 오타가있어서 솔루션이 완벽하게 작동합니다. 감사합니다. – hari

관련 문제