Hey, Mark.  You should look at using JSTL for this.  You could do
something like:

<display:table name="data" uid="user">
   <display:column property="username"/>
   <display:column title="XXX">
      <c:if test="${user.id == sessionScope.reseller.id}">
         <a href="xxx.jsp?id=${user.id}">Edit</a>
      </c:if>
   </display:column>
</display:table>

Something like that.  I'm not really following the logic in your
decorator, so I'm not sure exactly what you want to compare.  I also might
be mangling the notation to get the ID you have in the session for
comparison.  But this is pretty close to what you want to do.  Hit the
JSTL docs and you should be able to figure the exact notation out pretty
easily.

In general, I find using JSTL/EL in-line to be easier to manage than a
decorator, so I'm not sure of the answer to the question about getting the
current row in the decorator as opposed to the last row.  This question
was discussed on this list a couple of weeks ago, though, so you should
also do a search on that.

Mark Schrijver wrote:
> Hello all,
>
> I'm using the display-tag library to display a list of data on a
> website. However, I want to be able to conidionally show a value in a
> certain field, based on a session variable.
>
> Example:
> I have users who are registered to subscribers. I also have a
> "superuser". The superuser can view all the other users, but only the
> subscriber to which the user is registered can modify the user.
>
> This should result in 2 collumns, username, edit.
> In the edit collumn, I need a link to the editUser page, but that link
> should only be shown when the user looking at the page is the subscriber
> to which the user is registered.
>
> I have the subscriberId of the logged in subscriber stored as a session
> variable, and I have the subscriberId to which the user is registered
> sotred in the User object I put in the list used with the displayTag.
>
> I tried the following in a DisplaytagColumnDecorator:
>         User reseller =
> (User)pageContext.getSession().getAttribute("user");
>         Number number = (Number)pageContext.getAttribute("numberRow");
>         if (number.getResellerId() == reseller.getId()) {
>             return "<a
> href=\"deleteUserNumber.do?action=users.do&amp;numberId=" +
>                 number.getId() +
>             "\" class=\"remove\">" + number.getId() + "</a>";
>         } else {
>             return "";
>         }
>
> However, the line Number number =
> (Number)pageContext.getAttribute("numberRow"); always results in the
> last row of the list...
>
> Does anyone have any ideas on how to solve this?
>
> Mark Schrijver
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV_______________________________________________
> displaytag-user mailing list
> displaytag-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/displaytag-user
>


-- 
Rick Herrick
[EMAIL PROTECTED]

I haven't got time for inner peace.

"No reasonable definition of reality could be expected to permit
this."--Albert Einstein, Boris Podolsky and Nathan Rosen in 1935


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to