File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes On htm:multibox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "On htm:multibox" Watch "On htm:multibox" New topic

On htm:multibox

Hiroyuki Suzuki

Joined: Jul 25, 2007
Posts: 24
hello again...

I have this situation, If radio button A is chosen, it will require to choose from the multibox (I have 5 boxes).
Now, I used requiredif to validate multibox: bitratebox[0] to bitratebox[4]..
Sample validation.xml

problem is, when i do not select bitratebox[0], validation is not performed
even if I selected other other words, bitratebox[0] should also be selected in order to perform validation.

Am I missing something here?

How do I used multibox array? I mean how do I access the index of the array?

Please help me...

Hiroyuki Suzuki

Joined: Jul 25, 2007
Posts: 24
hello there again..
let me elaborate my question because i find it complicated.. :=)

The multibox property "bitrate" has 5 possible values in order{"500k","1M","2M","5M","6M"}
I can select any number of bitrate.

Question 1: if i choose to check 500k and 2M, the value of bitrate is
bitrate[0] = "500K"
bitrate[1] = "2M" ?

Now, after Ive selected 500K and 2M, i have to validate corresponding textbox for this bitrate.

Question 2: Im planning to do it this way on Validation.xml

for 500K validation,
i used bitrate[0] because its the only possible location for 500K..(dnt know if my idea is correct)

For 2M validation
i used bitrate[0],bitrate[1],bitrate[2] because i thought its the possible locations for 2M

Is this possible? because its not working for me, maybe i miss something.

also i declare bitrate in my Action form as

and my jsp is

Please help doing this for almost a day..
Its hard to be newbie.. :=)

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864

I warned you when I first told you about the validwhen validation rule that it does not cover complicated scenarios. It appears that your requirement is too complicated for validwhen to handle. You have two options:

1- You can override the validate(..) method in your ActionForm class and write your own logic for this validation. You can still perform the Validation Framework validations by calling super.vaidate(...).

2- You can write a custom validation rule. The validator guide has instructions on how to do this as well as an example.

Consultant, Sima Solutions
Hiroyuki Suzuki

Joined: Jul 25, 2007
Posts: 24
Hello Everybody..
Hello Merril...

Im using requiredif.. it seems to be working a little bit but not successfully..

My friend suggested to use iteration on my multibox..
Based from the tutorials I've read which is something like this

I want to convert my jsp like the above format

My JSP looks like this

wherein "bitratebox" is the multibox Im trying to validate..

I tried to code the above JSP using iteration..
and I made this

My Action Form

Are my codes correct??
this is the error

Please help me with the correct code..
Thank you..
Hiroyuki Suzuki

Joined: Jul 25, 2007
Posts: 24
Hello everyone..

forget about my question above, ive already made a solution for multibox

my JSP

I only made 1 iteration which produces
5 rows and each row contains 1 checkbox, 1 text box and 1 multibox

my ActionForm

Now I will start the validation method..hope I can make it works..
Hiroyuki Suzuki

Joined: Jul 25, 2007
Posts: 24
Before I proceed to validation..I encountered strange result again with my
multibox "bitratebox".
The selected box does not reflect on the next page when I submit the form.
Do I miss something in my logic:iteration method?

Please help me..

Hiroyuki Suzuki

Joined: Jul 25, 2007
Posts: 24
Gomen nasai..Im sorry
Dont mind again the question above..
I just made some mistakes on my JSP..

Thank you..
Ranjit Gopinathan
Ranch Hand

Joined: Jul 03, 2007
Posts: 46
In your second page, check if the "bitratebox" variable in the actionform is having the values selected in the previous page.
Hiroyuki Suzuki

Joined: Jul 25, 2007
Posts: 24
Thanks for answering..I already resolved this problem..
Gopinath Chinnakaruppan

Joined: May 17, 2007
Posts: 3

I am also looking for similar functionality. When i select a value from drop down. I need to show fields to search depending on the selection.

label1 operator1(dropdown) value1(text/dropdown)
label2 operator2(dropdown) value2(text/dropdown)
label3 operator3(dropdown) value3(text/dropdown)
label4 operator4(dropdown) value4(text/dropdown)

The no of rows will be vary. Right now I have the changed the visibility of the values.

<td>Name1  </td>
<td><html:select property="operator1">
<option value="SEARCH_OP_EQUAL" selected>= (equals)</option>
<option value="SEARCH_OP_CONTAINS">like</option>
</html:select> </td>
<td><html:text property="value1" /></td>

<td>Name2  </td>
<td><html:select property="operator2">
<option value="SEARCH_OP_EQUAL" selected>= (equals)</option>
<option value="SEARCH_OP_CONTAINS">like</option>
</html:select> </td>
<td><html:text property="value2" /></td>

How can i use logic iterate to achieve this accordingly.

Please help me out.
I agree. Here's the link:
subject: On htm:multibox
It's not a secret anymore!