struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Huber <gregh3...@gmail.com>
Subject <s:iterate> won't show tags on a pojo object
Date Thu, 08 Aug 2013 07:45:26 GMT
Hello,

There is probably not much you can do on this one, but I thought I would
post it if someone else was having the same issue.

I was trying to iterate over a pojo and it was not rendering the tags at
all.  I trace the source and found that on my pojo I had a method called
getTheme() which returned a WebsiteTheme class used in my webapp:

/**
     * Get the Theme object in use by this website, or null if no theme
     * selected.
     *
     * @return the theme
     *
     * @throws EventsException
     *             the events exception
     */
    @Transient
    public WebsiteTheme getTheme() throws EventsException {

        // let the ThemeManager handle it
        ThemeManager themeMgr = Controller.getThemeManager();
        return themeMgr.getTheme(this);
    }

On class org.apache.struts2.components.UIBean there is a method getTheme()
: where is searches via ongl : stack.findString("#attr.theme"); for a
method #attr.theme ie getTheme()

public String getTheme() {
        ......

        // If theme set is not explicitly given,
        // try to find attribute which states the theme set to use
        if ((theme == null) || (theme.equals(""))) {
            theme = stack.findString("#attr.theme");
        }

       ......
    }

Unfortunately it found the one on my pojo even though the return type was
not a String.  The solution is to either remove the getTheme() on the pojo,
or to specify the default theme on all the tags within the
<s:iterate><s/:iterate>.

Cheers Greg.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message