You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Moore <jo...@jmsd.co.uk> on 2005/01/07 18:56:01 UTC

Cannot find bean org.apache.struts.taglib.html.BEAN in any scope - Tiles problem?

I know this is an old one, and I know what the standard answer is, but 
the standard answer doesn't seem to apply in my situation here.

The standard explanation of this is that one is using, say, <html:text> 
outside of an enclosing <html:form>. What I have, though, is not simply 
that.

I have an html:form which uses a Tiles definition. Here's the calling form:

<tiles:insert definition="basicEditPage">
    <tiles:put name="postAction" type="string" 
value="/location/postCountry.do"/>
    <tiles:put name="fieldRows" type="string">
        <tags:textFieldRow label="ID" property="id" size="5" 
readonly="true"/>
        <tags:textFieldRow label="Country Name" property="name" size="40"/>
     </tiles:put>
</tiles:insert>

The Tiles definition looks like this:

<tiles-definitions>
    <definition name="basicEditPage" path="/WEB-INF/jsp/editObject.jsp">
        <put name="postAction" value=""/>
        <put name="fieldRows" value=""/>
    </definition>
</tiles-definitions>

This is editObject.jsp:

<c:set var="postAction">
    <tiles:getAsString name="postAction"/>
</c:set>
<html:form action="${postAction}">
    <table width="500" border="0" cellpadding="4" cellspacing="0">
        <tiles:get name="fieldRows" ignore="false"/>
    </table>
</html:form>

The tags in the calling form are JSP 2.0 tags, defined in a tag file 
like this:

<%@ taglib prefix="html" uri="/WEB-INF/tld/struts-html.tld" %>
<%@ tag body-content="scriptless" %>
<%@ attribute name="label" required="true" %>
<%@ attribute name="property" required="true" %>
<%@ attribute name="size" required="false" %>
<%@ attribute name="readonly" required="false" %>
<%@ attribute name="maxlength" required="false" %>
<%@ attribute name="errorMessage" required="false" %>

<tr>
    <td>${label}</td>
    <td>
        <html:text property="${property}" size="${size}" 
readonly="${readonly}" maxlength="${maxlength}"/>
    </td>
</tr>

So, what is happening, or should be happening, is that the calling form 
should be ending up being populated with a number of <tr> elements 
containing <td> elements containing <html:text> tags. So, ultimately the 
<html:text> tags do appear within proper enclosing <html:form> tags.

The question is, then, is the problem occurring because the <html:form> 
tags are being evaluated at one of the earlier stages, as it were, 
before they end up nestling between the <html:form> tags? What puzzles 
me is that the problem only occurs when using Tiles to do the assembly 
of parts. That is, the following works fine, even though the <html:form> 
tags are within the tag file:

<html:form action="/location/postCountry.do">
    <table width="500" border="0" cellpadding="4" cellspacing="0">
        <tags:textFieldRow label="ID" property="id" size="5" 
readonly="true"/>
        <tags:textFieldRow label="Country Name" property="name" size="40"/>
     </table>
</html:form>

Could it be a question of scope?

I've run into a similar problem before and did not resolve it then but 
worked around it instead. I hope for more success this time.

JM

-- 
==============================================
John Moore  -  Norwich, UK  -  john@jmsd.co.uk
==============================================

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org