Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to pass the Arraylist as it is from gsp page to controller action in grails
    primarykey
    data
    text
    <p>I've passed the arraylist values from my controller to a gsp page, there I can access the data of the arraylist by using the key names. In that gsp page I've added the following link in my gsp page like</p> <pre><code>&lt;g:link controller="searchFun" action="seeMore" id="" params="[q:params.q,cat:params.cat,stat:'study',ids1:'sm']"&gt;See More&lt;/g:link&gt; </code></pre> <p>When I access the same parameter in other seemore.gsp, I can not access the values by using the key name like this <code>"${fieldValue(bean: result, field: "purpose")"</code>, It throws an exception <code>"No Such property is available for Java.lang.String"</code> But I can use the same code in the <code>index.gsp</code>, there the above code works.</p> <p>My question is how the variable can be passed to another action as it is?</p> <p>Here is my controller and actions</p> <pre><code>*class SearchFunController { def searchableService def index() { def Study def map1=new ArrayList() def tmpStudy=Study1.search(query,[max:500]) Study=tmpStudy.results Study.id.each{ def c=Study1.findAllById(it.value) if(c!=null&amp;&amp;c.size()&gt;0){ c.each{ def sui=it.uniqueIdentifier def sur=StudyUserRole.findAllByStudyUIAndUserName(sui,session.user) if(sur!=null&amp;&amp;sur.size()&gt;0){ sur.each { def stu=Study1.findAllByUniqueIdentifier(it.studyUI) def loSui=it.id stu.each{ if(map1==null&amp;&amp;map1.size()==0) map1.add(it) else if(!map1.containsAll(it)){ println "Added here 2" map1.add(it) println map1 return [study:map1.unique()] }}}}}}}} def seeMore() { return [s:params.s] }* </code></pre> <p>index.gsp</p> <pre><code>*&lt;tbody&gt; &lt;g:each var="result" in="${s}" status="index"&gt; &lt;g:if test="${index&lt;5}"&gt; &lt;tr style="max-height:10px;overflow:hidden;"&gt; &lt;td&gt; ${index+1} &lt;/td&gt; &lt;g:if test="${fieldValue(bean: result, field: "uniqueIdentifier")!=null}"&gt; &lt;td&gt;&lt;g:link controller="searchFun" action="view" id="${fieldValue(bean: result, field: "uniqueIdentifier").replaceAll("\\[", "").replaceAll("\\]", "")}" params="[q:params.q,cat:params.cat]"&gt;${fieldValue(bean: result, field: "uniqueIdentifier").replaceAll("\\[", "").replaceAll("\\]", "")}&lt;/g:link&gt;&lt;/td&gt; &lt;/g:if&gt; &lt;g:else&gt; &lt;td&gt;--&lt;/td&gt; &lt;/g:else&gt; &lt;g:if test="${fieldValue(bean: result, field: "name")!=null}"&gt; &lt;td style="width:40%; height:2px; overflow:hidden;"&gt;${fieldValue(bean: result, field: "name").replaceAll("\\[", "").replaceAll("\\]", "")}&lt;/td&gt; &lt;/g:if&gt; &lt;g:else&gt; &lt;td&gt;--&lt;/td&gt; &lt;/g:else&gt; &lt;g:if test="${fieldValue(bean: result, field: "protocolType").equalsIgnoreCase("[null]")}"&gt; &lt;td&gt;--&lt;/td&gt; &lt;/g:if&gt; &lt;g:else&gt; &lt;td&gt;&lt;g:set var="dc" value="${fieldValue(bean: result, field: "protocolType").replaceAll("\\[", "").replaceAll("\\]", "").split(" ")}"&gt;&lt;/g:set&gt; ${dc[0].capitalize()} &lt;/td&gt; &lt;/g:else&gt; &lt;g:if test="${fieldValue(bean: result, field: "purpose").equalsIgnoreCase("[null]")}"&gt; &lt;td&gt;--&lt;/td&gt; &lt;/g:if&gt; &lt;g:else&gt; &lt;td&gt;&lt;g:set var="dc1" value="${fieldValue(bean: result, field: "purpose").replaceAll("\\[", "").replaceAll("\\]", "").split(" ")}"&gt;&lt;/g:set&gt; ${dc1[0].capitalize()} &lt;/td&gt; &lt;/g:else&gt; &lt;g:if test="${fieldValue(bean: result, field: "statusId").equalsIgnoreCase("[null]")}"&gt; &lt;td&gt;--&lt;/td&gt; &lt;/g:if&gt; &lt;g:elseif test="${fieldValue(bean: result, field: "statusId").equalsIgnoreCase("[1]")|| fieldValue(bean: result, field: "statusId").equalsIgnoreCase("1")}"&gt; &lt;td&gt;&lt;span class="label label-success"&gt;Available&lt;/span&gt;&lt;/td&gt; &lt;/g:elseif&gt; &lt;g:else&gt; &lt;td&gt;${fieldValue(bean: result, field: "statusId").replaceAll("\\[", "").replaceAll("\\]", "")}&lt;/td&gt; &lt;/g:else&gt; &lt;/tr&gt; &lt;/g:if&gt; &lt;/g:each&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;div class="span12"&gt; &lt;g:link controller="searchFun" action="seeMore" id="" params="[s:s]"&gt;See More&lt;/g:link&gt; &lt;/div&gt;* </code></pre> <p>In index .gsp its worked and i can see the data, but when i clicke the seemore link in the seeMore.gsp it throws an error. The same gsp code I used in seeMore.gsp too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload