Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Wilson Gordon

Ranch Hand
+ Follow
since Apr 07, 2007
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 Wilson Gordon

Hi all,

In my valdiation.xml file, I have the following validation for a field that should be in this yyyy-MM-dd HH:mm:ss format.

<field property="myTimestamp" depends="required, date">
<arg0 key="myTimestamp" resource="false"/>
<arg1 key="yyyy-MM-dd HH:mm:ss" resource="false" />
<var>
<var-name>datePatternStrict</var-name>
<var-value>yyyy-MM-dd HH:mm:ss</var-value>
</var>
</field>

The straneg thing is when the value in the form field matches the specified format, it still gives the error "myTimestamp should be in yyyy-MM-dd HH:mm:ss" format.

When I change the form field value to just yyyy-MM-dd, strangely it passes the validation.

Any idea how to get yyyy-MM-dd HH:mm:ss validatin to work?

I use Struts 1.1.

Thanks.
[ May 07, 2008: Message edited by: Wilson Gordon ]
12 years ago
Yeah, input looks fine. I use tiles and for input and put a valid tiles definition name there. Ex. input="search.page"

I wonder if the problem is due to the way I display the form.
When user clicks the menu link, it invokes a displayForm method in the action. And when user submits the form, it invokes the doSearch method. I don't think that's an issue though.
12 years ago
I got struts validator's client side validation to work, but for some reason the server side validation doesn't.

Currently if I don't include the

<html:javascript formName="searchForm"/>

to the page, after I put in some invalid values and click submit, it displays a blank page. if I don't put in invalid values, the search results get displayed properly.

It looks like server side validation particially works... but somehow coudn't displayed the page with the validation error message properly.

Any idea how I could fix this problem?

Thanks for your help.
12 years ago
Thanks for the info, Merrill.

The validWhen rule looks useful, althoguh for now I got around the problem when putting the form in an include file and in taht file I have logic to determine whether to show the field for the search type, or make it hidden.
[ April 21, 2008: Message edited by: Wilson Gordon ]
12 years ago
I am having trouble getting validator to work for a form bean that's shared by different pages. The way I have it set up is as follows:

1) I have a DynaValidatorForm named "searchForm". The form bean has 8 properties.

2)The form bean is used by 5 different JSP search pages, each for different search type. Each of the 5 JSP search pages uses some of the 8 properties, but none of them use all 8.

3) All 5 JSP search pages use the same action, and each JSP search page has a hidden "searchType" variable which determines the type of the search.

4) For each type, the action fetches form data needed for the particular search type. If it uses 3 of the 8 form bean properties, only those 3 are used.

So far it looks like if I make the form bean properties exactly same as the properties used on a search page, the valdiator works. For example, if a search page uses 4 of the 8 properties, commenting out the 4 unused properties in the Struts config make the valdiator work, or alternatively, adding 4 hidden form fields for those unused form properties to the page.

Is there a better way to get validator to work for this kind of setup?

Thanks in advance for your help.
[ April 21, 2008: Message edited by: Wilson Gordon ]
12 years ago
Thanks Merrill. Looks like that will work.

I'll try it tomorrow.
12 years ago
Is there a quick way to copy data from a DynaActionForm bean into a HashMap?

I tried using Beanutils's copyProperties method but it doesn't wrork:

PropertyUtils.copyProperties(userForm, testMap);

Thanks in advance for any help.
12 years ago
Weblogic 8.1.

I think you are correct, Bear. I did a search and found this in the 8.1 documentation:


WebLogic Implementation of JSP

BEA WebLogic JSP supports the JSP 1.2 specification from Sun Microsystems. JSP 1.2 includes support for defining custom JSP tag extensions. (See Programming JSP Extensions)

The WebLogic Server implementation of the JSP 1.3 specification calls getOutputStream rather that getWriter to output characters in a JSP. This can cause certain extended characters to be truncated and to appear incorrectly. Using HTML code for extended characters such as the Angsrtom unit and the degree symbol will ensure that they will be processed correctly by your WebLogic Server instance.

WebLogic Server also supports the Servlet 2.3 specification from Sun Microsystems.


So it only supports JSP 1.2...

But do you know why putting the EL inside that test condition works?
[ December 10, 2007: Message edited by: Wilson Gordon ]
12 years ago
JSP
Right. I found out if I use ${param.selectedPage} directly on the page, it doesn't get parse. But if I put it inside <c:choose><c:when test="${param.selectedPage == 'summary'}"... etc>, the test condition gets parsed ok.

It's weird but at least I got the tab menu to work this way.

Thanks.
12 years ago
JSP
Good point. By "doesn't work" I meant the EL didn't get parse in the tabs.jsp include file. It's strange, because in the JSP that has the tab menu include, there are EL and those get parsed without problem.
12 years ago
JSP
Hi,

I am trying to make a tab menu that highlights the tab when the page is selected. The tab menu is included via JSP include. Below are my codes? It doesn't work for some reason. Can someone tell me what's wrong? Thanks.

How I include the file:



tabs.jsp content:

12 years ago
JSP
I also tried the following and it didn't redirect me to Google. Looks like I can't modify the response for some reason.

chain.doFilter(wrappedRequest, wrappedResponse);
response.sendRedirect("http://www.google.com";);

Anyone know how I could resolve the problem?

Thanks.
12 years ago
Here is my doFilter method code:

The cookie doesn't get set for some reason. Any idea?
[ October 31, 2007: Message edited by: Wilson Gordon ]
12 years ago
Hi Jeane,

Thanks for the reply.

I added some logging and looks like the filter does get invoked.

What I try to achieve is to alter the response to add cookies from the session attributes. To do that, I created a wrapper class that implements the HttpResponseWrapper interface, and passed the wrapped response object into the chain filter. Below the chain filter call, I called addCookie method on the response object. The strange thing is the cookies don't seem to get added.

Any idea?
12 years ago
Hi,

I tried to add a filter to my application to filter requests, but it doesn't seem to intercept any request. Is there a problem with using filter and Struts together? How can I get it to work?

Thanks.
12 years ago