Cam Cres

Greenhorn
+ Follow
since Apr 16, 2010
Merit badge: grant badges
For More
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 Cam Cres

Hello. I'm trying to populate a select field with options coming from an array list. I cannot use optionsCollection because I have to assign an id to every option element (it's a requirement I cannot bypass). My idea was to use an iterator within the select tag, but i get an JSP compile exception. It has to do with the way I add the value attribute in the option element. Below is the code:



It doesn't even compile. It complains that codeBean cannot be resolved.

When I try:



There is another exception. Now it says there is a problem in the attribute codeBean.

Any suggestions? Thanks in advance for your time...
13 years ago
Hello guys:
I'm trying to extend the default validators that come with the Struts Validation framework. This is the entry in my validation-rules.xml for my new custom made validator

<!-- My OWN defined validators -->
<validator name="positiveInt"
classname="com.aexp.webproj.validators.MyOwnValidator"
method="validatePositive"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionMessages,
org.apache.commons.validator.Validator,
javax.servlet.http.HttpServletRequest"
depends=""
msg="errors.positive">

<javascript><![CDATA[
function validatePositive(form)
{
return true;
}]]>
</javascript>

</validator>

Whenever I do server side validation it works. I can properly see a message stating that the field in question is not a positive integer. I did that in MyOwnValidator class. My problem is when I try to do client side validation. I tried to write a javascript funcion with the same logic that the method that does the server side validation and I passed it within the <javascript> element as in the example above. But I could not get any message or pop up I as got with the default validators. Then I tried returning false or true to experiment results, and nothing ever happened.
What I'm missing. Can someone explain how javascript validation works? Do I have to provide my own javascript code for every custom validator or there is a workaround to that?
I tried viewing the source of the final rendered page and I still could see that my validatePositive(form) exists. Also the message that is supposed to be displayed is there. Then why is nothing happening?

Thanks
14 years ago