File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts Tag Library Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Tag Library" Watch "Struts Tag Library" New topic
Author

Struts Tag Library

suri jagadish
Greenhorn

Joined: Sep 14, 2005
Posts: 19
Hi ,
I am developing a web application which does not use the struts framework but i want to use the tag libraries that are provided by struts. like the html tags etc. can some body help me in providing the information about what are the jar files that i have to use.
Gayathri Chowduru
Ranch Hand

Joined: Oct 17, 2007
Posts: 42
Hi Jagadish,

You can do that in two ways. You can use any of the IDE that supports struts framework. Like MyEclipse, NetBeans etc.. Or else,

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>

you can use these declarations in the jsp and to your project libraries, add the struts.jar file.

you can check a simple web application using struts with NetBeans IDE from below link..

http://www.netbeans.org/kb/50/quickstart-webapps-struts.html

Thanks,
Gayathri Chowduru.
suri jagadish
Greenhorn

Joined: Sep 14, 2005
Posts: 19
Hi,

Thanks for the reply. But i mentioned very clearly that i don't want to use the struts framework. i.e No Action Classes, no struts-config.xml nothing.
i only want to use the tag libraries. I had put the struts.jar in the WEB-INF/lib but iam not able to use those taglibs since it insists in the ActionMappings not found...
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
I don't think you will be able to use Struts tags without Struts framework.I am not sure.
You can use JSTL.But JSTL doesn't support HTML tags.
Gayathri Chowduru
Ranch Hand

Joined: Oct 17, 2007
Posts: 42
Hi Gowher Naik, you are true... We can't use struts tags without struts framework..

Jagadish, if you need only the html tags, you can include in your jsp the below declaration.

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>

This will work for the static presentations only.. If you need the actions for controls, you should use the struts framework.

For my understatnding of your requirement, this is the solution.

Thanks,
Gayathri Chowduru.
suri jagadish
Greenhorn

Joined: Sep 14, 2005
Posts: 19
Hi,
what do you mean by static presentations only?
my requirement is that i need the html:select which automatically selects a particular value from the options, which we pass into the tag.
Gayathri Chowduru
Ranch Hand

Joined: Oct 17, 2007
Posts: 42
I understood. I am giving you a simple example..Check it..

myExample.jsp
-------------

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<html:html>
<head>
<script type="text/javascript">
function getTheValue(){
var Index = document.myForm.user.selectedIndex;
var Value = document.myForm.user.options[Index].text;
alert(Value);
}
</script>
</head>
<body>
<form action="" name="myForm">
<html:select name="user" property="user" onchange="getTheValue()">
<html ption value="ibm">IBM</html ption>
<html ption value="lenovo">Lenovo</html ption>
</html:select>
</form>
</body>
</html:html>

run this jsp page and let me know whether this is your requirement or not.. :-)

Thanks,
Gayathri Chowduru.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Suri,

What you are trying to do... use Struts html tags without using the rest of the Struts framework... is simply not possible. Here's why:
  • html:xxx tags must always be enclosed in an html:form stanza. The required action attribute of this tag must point to a Struts action. It cannot point to a servlet or JSP.
  • The property attribute of any html:xxx tag must correspond to a property on an ActionForm bean. The ActionForm bean must in turn be associated with an action class
  • Given these restrictions, I don't see any way of using the Struts html:xxx tags without using the rest of the Struts framework.


    Merrill
    Consultant, Sima Solutions
    suri jagadish
    Greenhorn

    Joined: Sep 14, 2005
    Posts: 19
    Hi Merrill,

    you are right i also came to know that it is not possible to use the struts html tags without the struts framework.

    Thanks for all of you who have answered....
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Struts Tag Library