logic:present and logic:equals problem

Discussions

Web tier: servlets, JSP, Web frameworks: logic:present and logic:equals problem

  1. logic:present and logic:equals problem (3 messages)

    Hi,

    i try to unserstand the struts taglibs and have some problems with tags and beans.

    I stored a User-Bean (Class myapp.UserBean) in the session.
    Now i want to check, if this Bean is present in the session and if it is, i want compare a variable from this Bean (UserBean.gid) with a value.

    My problem is, that this is not working:

    <logic:present name="UserBean" scope="session">
    <logic:equal name="UserBean" property="gid" value="1">
    ......
    </logic:equal>
    </logic:present>

    How can i access the Bean and its variables from the logic tags?

    Thx
    Naggi

    Threaded Messages (3)

  2. I would probably use JSTL instead of Struts logic tags here, they should always be preferred, but in lieu of that

    The name attribute in your tags is the first parameter used in the setAttribute() method of the Action class (assuming that you were using a Struts Action to set that bean in the session). Hopefully that helps with the outer tag.

    Make sure that the getter/setter methods for the gid property are properly named by convention for the bean.
  3. I guess you'll have to use the session attribute assigned to the instance instead of the class name. eg. if the instance was stored under the attribute session.setAttribute("userInfo", obj), then try using userInfo instead of UserBean etc..

    Hope this helps,

    Rakesh.
  4. Nice....[ Go to top ]

    it works...

    i had wrong get/set-methods for the parameter in my Bean :-)