You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tony Herstell <to...@cambridgesoftware.co.nz> on 2005/11/19 20:36:13 UTC

Mandatory disabled fields

Is there a way to define a “depends on” attribute (like Struts)?

 

I want a field mandatory, but it’s disabled (not even visible actually)
until a radio button is pressed.

 

Javascript is clever enough to ignore the request to have it mandatory but
Tapestry back end validation (in 3.0.3) still treats the missing field as an
error, which kinda makes sense  as it does not know the filed was disabled
which is the clue the Javascript has.

 

Struts gets around this by using “valid when”… so you only have it “checked”
at the back end when some condition is met (like the selection of the radio
button).

 

 Nasty Workaround =

            public void process(IRequestCycle cycle) {

 

                        IValidationDelegate delegate = (IValidationDelegate)
getBeans()

                                                .getBean("delegate");

                        if (delegate.getHasErrors()) {

                                    // return; <--Ignore the errors (Trust
to Javascript and/or check for ones that you really want to report on – lots
of code to re-invent the wheel!!)

                        } else {

                                    // Do other validation as required.

                        }

                        cycle.activate("MainMenu");

            }

 

Cheers.


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.4/175 - Release Date: 18/11/2005



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.4/175 - Release Date: 18/11/2005