aspose file tools*
The moose likes Struts and the fly likes Struts: Can we have a html:text tag without a html:form tag outside it. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts: Can we have a html:text tag without a html:form tag outside it." Watch "Struts: Can we have a html:text tag without a html:form tag outside it." New topic
Author

Struts: Can we have a html:text tag without a html:form tag outside it.

Amith Mahalingaiah
Greenhorn

Joined: Jul 12, 2004
Posts: 7
hi guys,

i just wanted to know whether we can have a <html:text> tag without a <html:form> tag.

for example
Index.jsp

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>

<html:text property="uid"/>
<html:text property="uid"/>
<html:submit property="submit"/>

</html:html>
--------------------------------------------------------------------------
web.xml

<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

---------------------------------------------------------------------------
struts-config.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">


<struts-config>

</struts-config>
----------------------------------------------------------------------------

when i run the index.jsp without the <html:form> tag, it gives me an error

org.apache.jasper.JasperException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope


to counter this exception i modified my jsp to

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>
<html:form action="">
<html:text property="uid"/>
<html:text property="uid"/>
<html:submit property="submit"/>
</html:form>
</html:html>

..........now i get an error

org.apache.jasper.JasperException: Cannot find ActionMappings or ActionFormBeans collection

....i understand what the error means. But is there any way to just view a jsp page using the <html> tags provided by struts without using any forms, formbeans, and Action.

i just want to use the taglib <html> which struts provide.

If the answer is that i cannot use <html:text> without a <html:form> outside it....why is it so?

-Amith
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 5019
    
    8

Originally posted by Amith Mahalingaiah:
If the answer is that i cannot use <html:text> without a <html:form> outside it....why is it so?
-Amith


As far as I can tell from what the Struts documentation says, you can't use the text tag outside a form tag. I suspect it has to do with the text tag using the enclosing form's associated ActionForm bean by default as the source of property values used to pre-populate the input field.


Junilu - [How to Ask Questions] [How to Answer Questions]
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30973
    
159

Do you have the <form> tag around the struts tag? If not, the HTML being generated is invalid.

A workaround I use is to reate an <html:form> with some action and use javascript to prevent it from submitting. And of course a comment to explain what I am doing!


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts: Can we have a html:text tag without a html:form tag outside it.