steve francisco

Ranch Hand
+ Follow
since Jan 26, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by steve francisco

Originally posted by alan do:
you can place the form bean in session by specifying the action mapping's 'scope' attribute to 'session'...e.g scope="session". the form bean mapped to the action mapping will be placed in the session scope. remember to clear the form values out when you are done with them.



thanks. since we usually don't need ALL of the information from a form, I want to selectively store some information and carry them over pages. Thus, I want to use session.setAttribute() in the Action classes. It should work, right ?
14 years ago
can someone give me a sure answer ?
14 years ago
In JSP1 --> Action1 --> JSP2 --> Action2 --> JSP3-->Action3-->JSP4, we have
Form1Bean, Form2Bean, Form3Bean matching JSP1, JSP2, JSP3.

We need to carry over the information from JSP1(Form1Bean) to 2nd and 3rd page and more.. It seems the easiest way is to put scope="session" in the "action" tag in config-struts.xml. But besides doing that, do I need to explicitly write "session.setAttribute("Form1", Form1Bean);" (or explicitly do setAttribute() for every object I want to carry over pages) ? I am wondering if I only put "scope=session" in xml and skip doing this "session.setAttribute", can I still access "Form1Bean" in "Action3" class ?
14 years ago
I have an application looks like

In the first page it asks you to choose if you're a

a) new student
b) old student
c) part time student

Then

if you are "new student" you go through "Registrtion.jsp" -->"OpenAccount.jsp"-->"Course.jsp"

if you're old student, you go thorough "Registration.jsp"-->"Course.jsp"

if you're part time, go through "Registration.jsp"-->"CreditHour.jsp"

I want to create and maintain as few JSP as possible. SO, for "Registration.jsp" page it has 3 possible destinations.
I decide to use 3 different "DispathAction" classes for three student types. So I will create the following mapping:

<action path="/newStudent" type="org.apache.struts.actions.DispatchAction"
name="RegistrationBean", input="/registration.jsp">
<forward name="success" path="/OpenAccount.jsp"/>

<action path="/oldStudent" type="org.apache.struts.actions.DispatchAction"
name="RegistrationBean", input="/registration.jsp">
<forward name="success" path="/Course.jsp"/>

<action path="/partTime" type="org.apache.struts.actions.DispatchAction"
name="RegistrationBean" input="/registration.jsp">
<forward name="sccess" path="/CreaditHour.jsp"/>

This way, given a "Registration.jsp" I have 3 different destinations by calling three different "path" in action. Does this make sense ?
14 years ago
In my JSP, it looks like
****************
<% String age = session.getAttribute("Age").toString();
String choice;
if(age.equals("senior")) choice = "MULTIPLE";
else choice = "SINGLE"; %>

<SELECT NAME="ITEMS" <%= choice %>>
<OPTION VALUE="item1">item1
<OPTION ...
...
</SELECT>
*****************

It may have some typo here. But the point is this JSP page can dynamically ask user to pick one or more items (sometimes one, sometimes more, depending on if you are senior member). Now suppose we have a "FormBean" matching this JSP, should I

1) create two "FormBean" class, in first one I put "private String item;" and in second class I put "private Collection item;" ?
2) or should I ONLY create one "FormBean" class and just put "private Collection item" ? The single item case should be covered by it anyway.

I guess I should take approach 2), is that right ?
14 years ago
I heard some people said "not to catch any exception" in Action or anywhere, just let them flow, struts can handle it and eventually it can be reflected in the JSP. Is that true ?

However, in one of my project, I am REQUIRED to redirect the page to a company customized error page when a specific exception appears. For example, if "No sufficient Fund exception" appears we need to direct to the bank's specific warning page. Is this doable and how ? please advise as I have not much struts experience yet.
14 years ago
If I need to display a picklist like

***
Elementary School
Grade one
Grade two
...
Middle School
Grade seven
...
High School
Grade ..
******

two questions ---

1. struts OPTION doesn't come with the index level. so how can I display this using struts tag ?

2. If I need to make only those "Grade" selectable and "Elementray/Middle" scholl titles unselectable, I have to use html OPTGROUP, does struts have similar thing ?

thanks
14 years ago
I have a web application with page flow like JSP1-->JSP2-->JSP3-->JSP4-->JSP5, between each two JSP pages it goes through servlet and some action classes. Now, suppose that in each JSP page, I want to use tag library to make the life easier. Do I need to create different Tag Handler classes for different pages ? i.e. do I need 4 or 5 different tag handler classes in this case ?
14 years ago
JSP
The API shows SAXParser.parse() method has to take 2 arguments, one is the File or InputSource and the 2nd one is the DefaultHandler. But in many samples I saw "parser.parse(file)" or "parser.parse(inputSource)" without the 2nd argument in the method. why ?
Learning SAX 101, what jar file do I need to include in the CLASSPATH ? where to download it ? I saw some people use apache xecers, is that a standard one and do I need to download xecers in order to use SAX ?
In my html page, I have an EXCEL file that I put on web server and want users to be able to download. However, <a href="Book.xsl">click to download</a> does not work. But after I zip this Excel file into a Book.zip file <a href="Book.zip">click to download</a> it seems it works, at least user can "save" it, but "open" has some problem still. I want to know --

1. why does HREF works with .ZIP but not .XSL ?

2. what if I just don't want to zip it and just want user to download the .xsl directly ? How can I do it ? Somebody says I have to put the .xsl on a FTP server instead of a web server. Is that right ?

thanks

Originally posted by alan do:
it's quite easy to accomodate what you are asking for...use DispatchAction. your 'parameter' attribute's value (which points to a method in the DispatchAction) would be in a hidden field in each of the forms. your URI will stay the same while each time the action will different.



Thanks lot. I checked DispatchAction and MappingDispatchAction. They are all one Action class containing multiple action methods. It seems MappingDispatchAction doesn't suit my need because it uses different "path" names for each mapping; the DispatchAction looks good for my case because I can still use the same URI and either append with different "xxx" in "?method=xxx" or just pass it as a hidden variable. Excellent.
14 years ago
Thanks. In my page flow JSP1-->servlet-->action1-->JSP2-->action2-->JSP3-->.... Since they consists of ONE logical task and it is just broken into several pages for some reason, it will be nice that users see the same URI (like "submit.do" when they click "submit" button on JSP1, JSP2) instead of different URI (like "submit1.do", "submit2.do", "submit3.do" when they click "submit" button on JSP1, JSP2, JSP3).

Well, if there is no way to handle it, I guess I have to live with it. Just want to explain why I prefer to have a same "path" name in this scenario.
14 years ago
Thinking about a Giant food store product. Each has a product code associated with it. The food is grouped by big groups then by smaller groups. For example:

Milk (code: 01)
whole milk (code 01-11)
skim milk (code 01-12)
Bread (code: 02)
white bread (code 02-11)
.... (code 02-12)
Cheese (code: 03)
swiss cheese (code 03-11)
...

And for each product, we need its price, quantity, location, etc. User can pick from the lists and I need to display tables for the products they pick and it has to be grouped at the "2-digit" code level, i.e make a table for "milk" followed a table for "bread", etc.

I think of using "Hashmap" and the key is the "2-digit" code (like 01, 02, 03), for each key, there is an Arraylist associated with it. e.g. for "01" the arraylist includes few elements, each element includes the "4-digit" code, price, quantity. So when I print the tables, I iterate through the keys, for each key, I create a table displaying the Arraylist.

Is this a good idea or do you have better suggestion ?
14 years ago