Sab wrote:

I have one action defined in struts config file .


<action path="/itemsearch">
Name="itemsearchForm"
Scope="session"
type="com.my.ItemSearchAction">


I have defined in global forward the

<forward name="itemsearch" path=".my.itemsearch">

I have a tiles definition which takes me to Itemsearch.jsp

This jsp has 2 buttons.-Export and Cancel.
When I click on Export it takes me to another page called itemlist(which
again has 3 more buttons) page. When I click cancel it takes me to main
page .

How to connect the buttons to go to the further pages.
Please help!





Perhaps I don't understand your questions fully, but it seems like you are struggling with some basics here, so I'm going to try to give you a summary. Sorry if you already know all this (hard for me to tell).


The way you learn to "connect" buttons to facilitate page navigation is to first understand the basics of using HTTP in Servlet applications, regardless of Struts. In a typical scenario, the first user page (usually rendered as the response to a GET request -- a click on a hyperlink or direct entry into a browser address bar) contains an HTML form. An HTML form has at least two important parts, and usually three: The form fields (optional) for accepting user data, the action URL, which is where the browser's POST request will be sent, and the submit button, which causes the POST request (containing the user data if any) to be sent to the action URL. The server's response to the POST request is the next page your user will see. (Therefore, clicking the button on page 1 "takes" the user to page 2.) Struts does not abandon this concept for something else; it provides a framework that solidifies the concept for Servlet developers.

You generate an HTML form in a Struts JSP using the Struts Form (html:form) tag and related tags (all the other HTML tags). The use of these tags is all in the documentation under "User and Developer Guides". But, for example, you might combine the html:form tag, the html:cancel tag and the html:submit tag to create the simplest of forms. The tags just render HTML like any hand-made HTML form would contain, with added benefits (some of which are required by Struts) that will become clear as you learn to use Struts.

Servlets allow you to provide "virtual" action URLs on your Web server, basically, meaning that the action URL of your form (or the URL of a hyperlink for that matter) doesn't have to point to an actual HTML/JSP page that will be used in rendering the response. Rather, it can be a "logical" URL that triggers a server action -- typically this action does use some HTML/JSP page to render the response. The point is that the server gets a chance to interpret the URL and do interesting things *before* rendering the response, whereas a typical, dumb (non-Servlet, non-CGI enabled) Web server simply maps request URLs to response pages.

In the Struts world, these "virtual" URLs are your Action Mappings (such as yours with the "/itemsearch" path). The action URL (specified in your html:form tag) points to one of these Action Mappings. When the user clicks the submit button, the browser sends the POST request containing the form data to the server. The server, running Struts, routes the request to the Struts controller Servlet. The controller determines which Action Mapping matches the URL of the request (all configured in struts-config.xml), and consults the Action (your Java class) that corresponds to that mapping to manufacture the response (typically by examining the user's form input if any, gathering data from a database, putting the data in a place where the JSP needed to render the response can find it, and finally forwarding control to the JSP so that it can render the response using the gathered data -- the JSP serves as a template while the data gathered by the Action gives you the values that are not part of the template).

For me, the easiest way to get going with a new technology is to find an example that does something analogous to what I desire and to study it and then modify it for my circumstances. Have you tried going through some good examples? The wiki is a good place:

http://wiki.apache.org/struts/StrutsArticles

In particular, the second link ("Struttin' With Struts") was helpful to me when I was getting started, because the author gets right into it with examples, and the site is about as well organized as a tutorial site can be. Also, Struts comes bundled with a couple examples that you'll want to study (I would try a tutorial first).

So one more time, the basic parts involved in what you are trying to do:

1) a page containing an HTML form (rendered via JSP and Struts HTML tags -- this is page 1, which contains your button) with an action URL that corresponds to an Action Mapping
2) a response page (JSP) that is a template requiring data that is dynamic -- from your database -- to be complete (this is page 2)
3) an Action -- Java code that gathers the database data needed to complete the response JSP, makes it available to the JSP and then forwards to the JSP (forwarding means, in effect, "start writing a response to the browser that submitted the request")
4) an Action Mapping (an entry in struts-config.xml) that tells the controller Servlet what Action, JSP, etc., to use to respond to which action URL (looks like you already understand this part somewhat)
5) the controller Servlet (provided by Struts) which intercepts the request, parses the URL, finds the correct Action Mapping and uses that mapping to determine what Action and what JSP to use in rendering the response


I hope this helps.

Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to