views:

74

answers:

1

I have stripes:link tag in a jsp with an event attribute:

<stripes:link href="${actionBean.context.currentStage.stripesForwardAction}"  addSourcePage="true" event="showTab2Link">

This triggers the validation to trigger on nested properties:

    @ValidateNestedProperties({
    @Validate(field="county", required=true, minlength=2, maxlength=2, mask="\\d\\d"),
    @Validate(field="parish", required=true, minlength=3, maxlength=3, mask="\\d\\d\\d"),
    @Validate(field="holding", required=true, minlength=4, maxlength=4, mask="\\d\\d\\d\\d")
}) 

However this would been fine if the actual values it is validation are not present, but they are present within the html and when debugging the bean. Why would the stripes:link trigger this?
If I change it to an stripes:submit then it is fine.

thanks,

Dave

+2  A: 

The reason it's being triggered is because the stripes:submit must have the fields in the form, so those fields are transmitted to the server when the form is submitted. With the link, you don't get any fields unless you add them as link parameters.

You can fix this one of two ways, depending:

Do you want those fields present on the bean when the link is clicked? Then you'll need to populate the link with the params so they'll be added GET query-string style:

<stripes:link href="${actionBean.context.currentStage.stripesForwardAction}"  addSourcePage="true" event="showTab2Link">
<stripes:param name="county" value="${actionBean.county}" />
<stripes:param name="parish" value="${actionBean.parish}" />
<stripes:param name="holding" value="${actionBean.holding}" />
link text
</stripes:link>

On the other hand, if you don't need them in your bean for that event, you can tell your @ValidateNestedProperties to ignore that event:

@ValidateNestedProperties({
    @Validate(field="county", on="!showTab2Link", required=true, minlength=2, maxlength=2, mask="\\d\\d"),
    @Validate(field="parish", on="!showTab2Link", required=true, minlength=3, maxlength=3, mask="\\d\\d\\d"),
    @Validate(field="holding", on="!showTab2Link", required=true, minlength=4, maxlength=4, mask="\\d\\d\\d\\d")
}) 

Then the validation won't be run on the event showTab2Link unless it actually was supplied.

lucas
That makes sense, I'll give that a go.
Davoink