gtosto / struts2-arianna-plugin

A configurable struts2 breadcrumb like plugin
1 stars 3 forks source link

ExcludeParams #11

Open jordan1982 opened 8 years ago

jordan1982 commented 8 years ago

Hi, it's possible to exclude certain parameters from the crumbs? I need to remove refinements starting with "action ". I have tried using the params interceptor struts2 ( excludeParams ) but it did not work . Thank you

gtosto commented 8 years ago

Hi the short answer is : "no with the current implementation you cannot exclude parameters from the crumbs, all request parameters are always stored in the crumbs ". However their names and values are used just to check the "struts2 request equality", (that is if the same request is already presents in the bread crumbs) and only if the used comparator is the
Request Comparator. So you can provide your own implementation of a custom comparator that ignores the wanted parameters. See also RequestComparator.java for example. Instead, If you need to exclude such parameters from the link rendered by the bread crumb trail, again you can exclude such parameters by customizing the jsp fragment code see rendering of parameters.

I hope that this answer can help you, if no let me know.

P.S. I found that your needs are a common requirement, so i'm planning to make a such feature as a builtin, even if not in a shortterm.

jordan1982 commented 8 years ago

Thanks for the quick response. My requirement is to remove/exclude parameters starting with "action:" from the link rendered by the bread crumb trail. I have already read the documentation and already tried customizing the jsp, but unfortunately are not able to remove them (i . The bread crumbs work perfectly in form having only one submit. In forms that have more than one "s: submit", work correctly until you click one of these buttons (click on one of these buttons add a parameter " action:" and from that moment the crumb always returns to the last action performed by the button).

Excluding the parameter with params interceptor can solve the problem?

">^action:._,^method:._

Thank you

gtosto commented 8 years ago

Hi I am not sure to understand your issue.

  1. Can you provide an example that show the bad behaviuor and the desired behaviuor ?
  2. Which crumb comparator are you using ?
  3. How are mapped your actions ?
  4. What is your interceptor-stack ?

Anyway you can exclude the rendering of the "extra" action parameters by using the following fragment when building the url for crumb's link (in the body of the breadcrumb tag)

<s:url var="surl" action="%{action}" method="%{method}" namespace="%{namespace}" includeContext="false"/>

<c:url var="url" value="${surl}">
    <c:forEach items="${c.params}" var="p">
        <c:if test="${not fn:startsWith(p.key,'action:')}">
            <c:param name="${p.key}" value="${p.value[0]}"/>
        </c:if>
    </c:forEach>
</c:url>

Note the if tag to exclude the parameters starting with "action:"

Said this, I'm not sure that the above workaround will fix your issue, i believe that the correct behaviuor could be better achieved with a custom Crumb Comparator. Let me know.

To answer to your question regarding the params interceptor, i believe that the default configuration should already exclude those parameters, but such exclusion seems to me regards the ognl value stack.

Cheers Giovanni

gtosto commented 8 years ago

sorry wrongly closed :)