Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems a little strange that you'd need access to params in your tag closure since the output should really only depend on the tag attributes and the body. It's quite possible I have just misunderstood something, but if you need access to a request parameter in your tag I would expect the flow to be more like this.</p> <p>First in the controller, send the params value to the GSP View/Template:</p> <pre><code>//Some controller method def viewSomething = { render(view:'viewWithTag', model:['tableId':params.tableId]) } </code></pre> <p>Then in your GSP, set the tableId as an attribute on the tag so it doesn't need to know anything about the request parameters directly:</p> <pre><code>... &lt;renderAutoComplete tableId="${tableId}" /&gt; ... </code></pre> <p>Then in your taglib closure:</p> <pre><code>def renderAutoComplete = { attrs, body -&gt; def t = Table.get(attrs.tableId) ... } </code></pre> <p>Hope this helps! If I misunderstood your question let me know.</p> <p><strong>Update:</strong> </p> <p>Okay, I think I understand the point of confusion now. Rendering the output of your tag is inherently part of the response whereas the built-in params is inherently part of the request. So your tag cannot set request parameters directly. Part of the functionality of gui.autoComplete and its YUI counterpart is that it generates the URL that will be used later on to send an AJAX request to your action. That URL contains HTTP request parameters in the typical ?name=value form. Grails automatically will populate those into the params variable available to you in the action.</p> <p>This works much the same way as the grails createLink tag does. You can specify request parameters by defining a params attribute value:</p> <p><code>&lt;g:createLink action='act' controller='cont' params="[foo: 'bar', boo: 'far'] /&gt;</code></p> <p>Within the implementation of createLink it is just setting HTTP parameters and grails is shoving those into params so that you have them in the controller logic. As an aside, you may also be able to set request parameters by including the same params attribute in your call to gui:autoComplete. I haven't tested this, but the code that is used to implements this seems to ultimately do a pass through to the grails createLink and I think by coincidence it may set the request parameters for you.</p>
    singulars
    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.
    1. VO
      singulars
      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