views:

384

answers:

2

I have the following code.

<s:push value="#session['person']">
         <s:if test="%{admin=='y'}">
            <a class="add" href="/projit1/project/addProject.jsp">Create a Project</a>
        </s:if>
        </s:push>

I am trying push an object person from session map to valuestack and check one of its properties admin's value. If it is 'y' then the link "create a project" appears.

But this code is not working. If i use the above code, both admins and normal members does not see the link. what could be the problem ? please help

A: 

Try this.

    <s:push value="person">
      <s:if test="%{admin=='y'}">
        <a class="add" href="/projit1/project/addProject.jsp">Create a Project</a>
      </s:if>
    </s:push>
Adeel Ansari
i have the person object set in session map
lakshmanan
Session context is available here. Just like JSTL it would look for this attribute in page, then request, then session and then application. So, in your case the attribute should be found in session state.
Adeel Ansari
A: 

And you have a getAdmin() or isAdmin() on your Person object I assume? If that's the case, I also assume the method returns a char 'y'? I suggest you try displaying the result of calling admin and go from there. e.g.

<s:push value="#session['person']">
  admin: <s:property value="%{admin}" />
  <s:if test="%{admin=='y'}">
    <a class="add" href="/projit1/project/addProject.jsp">Create a Project</a>
  </s:if>
</s:push>
fmpdmb