Whitney Albrecht

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

Recent posts by Whitney Albrecht

I have a struts action that is getting data, converting it (transforming it w/xslt) and placing it directly on the HttpResponce, which goes back to the browser.

I set the following on the response variable:
setHeader("Content-Disposition", "attachment; filename" + filename);

If I use Firefox 1.5, when I click on the link (which calls the action), the download dialog box pops up with an option to save or open, then when I save or open the file the filename and extension is correct (g.txt). Howeever, when I use Netscape 7.02 and the dialog box pops us and I save and or open the file it add the additional .ax extension on the file name (*.g.txt.ax).

Anyone know why the difference in these two browsers? or why Netscape want to keep the struts action extension (.ax)?

13 years ago

i've always implemented my dropdowns this way...instead of putting the ArrayList in the form-bean, generate it in your initial action call and place it in the session scope (have a helper method to check to see if the collection exists already and generate only when necessary) and leave the reset method alone.

Do I need to create a similar setup where I have two action classes. Where one fills the ArrayList in (and sets it as an attribute) and one that handles the action? (jakarta.apache.org/struts/faq/newbie.html#prepopulate).

Am I on the right track?

Thanks for you help.
[ October 03, 2005: Message edited by: Whitney Albrecht ]
15 years ago
For further clarification here is my retyped code:

In my stuts-config.xml

<form-bean name="newJobForm"
<form-property name="list1" type="java.util.ArrayList"/>
<form-property name="selectionList1" type="java.lang.String"/>
<form-property name="list2" type="java.util.ArrayList"/>
<form-property name="selectionList2" type="java.lang.Long"/>

<action path="/NewJobForm"
<forward name="Success" path="program.newJobRouting"/>
<forward name="Failure" path="program.newJob"/>


In my ActionForm class I overwrote the reset class to fill in each ArrayList (from the Database) which in turn are used as drop downs in the Jsp.

In the JSP I have something similar to this:

<html:select property="selectionList1">
<logic:iterate name="newJobForm" property="list1" id="row">
<option value="<bean:write name='row' property='division'/> ">
<bean:write name='row' property='division'/> ---
<bean:write name='row' property='division_abbrev'/>


<html:select property="selectionList2">
<html ptionsCollection property="list2" label="sectionName" value="sectionID"/>

I have more fields on this form too. I have a form validator on this form. I understand if the required fields are not filled in of course the validator will throw it back and call the reset() again in my actionForm class.

My problem is that when the page reloads the dropdowns that were selected are getting reset.

15 years ago
I am having trouble with a form. When the validator throws the error all the drop-downs that have been selected get set back to default settings.

The form is in session scope. I have attempted in the reset method getting the values from the previous session with no avail.

I found this article


which might help me but can't find an archive or reference link to this article mentioned at the bottom

can anyone point me in the right direction?

15 years ago
To all having a similar problem,

you can use <html:cancel> with the LookupDispatch action ... you just need to override the cancelled function and replace it with what you want to do.

[ September 27, 2005: Message edited by: Whitney Albrecht ]
15 years ago
On my jsp page I have three buttons and a cancel button.

<html:submit property="direction">
<bean:message key="button1">
<html:submit property="direction">
<bean:message key="button2">
<html:submit property="direction">
<bean:message key="button3">
<html:cancel> Cancel </html:cancel>

When the cancel button is hit on the page I get the following error:
javax.servlet.ServletException:Request [/aForm] does not contain handler parameter named 'direction'. This may be caused by whitespace in the label text.

When the page came up I did a view source and the submit tags get rendered as:

<input type="submit" name="direction" value="button1">
<input type="submit" name="direction" value="button2">
<input type="submit" name="direction" value="button3">
<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onklick="bCancel=true">

Do I need to configure my own cancel button or how do I configure DispatchAction to recoginize the cancel button?

Thanks in advance.
15 years ago
I have tried implementing the NestedLazy Bean from:


However when I try to do something similar to the Order Book bean I get run into errors.

The first problem I run into is that since the customer does not exist (yet) I get a null returned from the following line:
DynaBean customer = (DynaBean)orderBook.get("customer", c);

So then I added a set method before the get;

orderBook.set("customer", c);
DynaBean customer = (DynaBean)orderBook.get("customer", c);

but ran when running the code ran into the ClassCastException error; which is thrown by the get line.

Has anyone been sucessful in using Nested Lazy beans? What am I missing or setting up wrong?

Thanks for you advice in advance.
[ September 09, 2005: Message edited by: Whitney Albrecht ]
15 years ago
I have a form in where I have setup when a "Add Channel" button is pressed it adds to a table a new html:text field.

in my struts-config.xml I have the following:

<form-bean name="channelProcessing" type="actionForm.job.ChannelProcessingActionForm">
<form-property name="channelCollection" type="java.util.ArrayList"/>

I have a bean class called ChannelProcessing.java which contains a getter and setter for a String value name channelNumber (along with other values which are used for html:text fields --- but I need to get help on this one in order for the rest to fall out).

Since there are several buttons on the page the ChannelProcessingAction extends the LookupDispatchAction class.

When the "Add Channel" button is pressed; inside the action I create a object of type ChannelProcessing and place it in the channelCollection ArrayList.

On the form I have the following logic loop:
</logic:iterate id="aChannel" name="channelProcesing" property="channelCollection">
Channel #: <html:text name="aChannel" property="channelNumber" indexed="true"/>

However when I get to the final submit I am unable to get the value of any html:text field that was entered in.

Can anyone tell me what my mistake is?

15 years ago
In my struts-config.xml I have:

<form-property name="chkbox1" type="java.lang.Boolean"/>

anActionForm.java extends DynaValidator form. And in the reset( ) method I am trying to set the checkbox value to false by the following:
set("chkbox1", false);

However when I compile I get the following error:
"Cannot resolve symbol: method set(java.lang.String, boolean);"

Can anyone see why the set method (inherited from the struts ActionForm class) will not accept a boolean value?

15 years ago

Thanks for seeing what I couldn't.
15 years ago
Can anyone help me find my mistake? I have a form with three fields (username, password, and encryptedPassword).

To start off with I am just trying to make sure the userName field is filled in.

In my struts-config.xml:
<form-propery name="userName" type="java.lang.String"/>
<form-propery name="password" type="java.lang.String"/>
<form-propery name="encryptPassword" type="java.lang.String"/>
<plug-in className="org.apache.stuts.validator.ValidatorPlugin">



<form name="authenticate">
<field property="userName" depends="required">
<arg0 key="authenticate.userName"/>

in applicationResorces.properties:
authenticate.userName=User Name
errors.required={0} is required.

When I deploy the project I get the following error:
[ValidatorPlugin] Loading validation rules from '/WEB-INF/validation.xml'
ERROR [ValidatorPlugin] java.lang.NullPointerException
at org.apache.commons.validator.ValidatorResources.internalProcessForms (ValidatorResources.java:464)
at org.apache.commons.validator.ValidatorResources.process(ValidatorResources.java:415)
at org.apache.commons.validator.ValidatorResources.<init>(ValidatorResources.java:162)

I am using struts 1.2.4 and JBoss.

Anyone have any ideas what I am missing or misstyping?

Thanks in advance.
[ July 26, 2005: Message edited by: Whitney Albrecht ]
15 years ago
The only work-around I found was to create a simple button that when it was pressed would call the action directly.

For example:
(syntax may not be correct but it will give you the idea)
< input type="button" onKlick="window='youraction.do'" >

this will bypass the validator and call another action.

Its not the best way but a work around for now.
15 years ago
YES! I tried sln #2 and it worked.

Thanks for pointing me in the right direction.

15 years ago
I'll go try it ... I'll let you know... thanks for the link to the post
15 years ago
I am using DynaValidator Action Form to do two things:
1) Dynamically create a table with radio buttons named "userRadioValue" in the UserManagement.jsp page (by mapping two actions similar to this example -- http://www.developer.com/java/ejb/article.php/3321521)

2) Verify that a radio button has been selected (when the submit button has been selected).

I have overwritten the DynaValidatorActionForm validate function. It displays the error on the jsp page but refreshes the jsp form and removes the dynamic information that was orginally displayed on the page.

Can anyone tell me how to get the validate function, if there is an error to recreate the page while still displaying the error?

[ July 07, 2005: Message edited by: Whitney Albrecht ]
[ July 07, 2005: Message edited by: Whitney Albrecht ]
15 years ago