开发者

Ajax Validation Without Persist

开发者 https://www.devze.com 2023-02-16 07:18 出处:网络
HI all, I\'m trying to set some validation in my Seam application & I have it working but it has a few side effects I\'d like to avoid.I\'ve set up the fields on my input form like开发者_运维技巧

HI all,

I'm trying to set some validation in my Seam application & I have it working but it has a few side effects I'd like to avoid. I've set up the fields on my input form like开发者_运维技巧 below:

<label for="displayName" class="required">Display Name:</label>
<s:decorate id="displayNameDecorate" styleClass="errorwrapper">
    <h:inputText id="displayName" value="#{presenceHome.instance.displayName}" required="true">
        <a4j:support event="onblur" reRender="displayNameDecorate" ajaxSingle="true"/>
    </h:inputText>
    <a4j:outputPanel ajaxRendered="true">
        <h:message for="displayName" styleClass="errormessage"/>
    </a4j:outputPanel>
</s:decorate>

This method works fine. If I enter a value that is considered invalid for display name, then it shows a validation error. The trouble I have is when the value entered is valid. When I tab out the field, the a4j:support fires off causing the data to be validated (which passes) and then persisted. Now if after tabbing into the next field I decide that I didn't want to edit this record, I can't cancel out, reverting my changes - my changes have already been persisted to the DB.

Is there anyway I can have the AJAX validation fire off but without any persistence occurring? Or do I just need to forget about the ajax validation and live with it firing off on form submit.


I'm not sure what's happening in the code you're showing, but would using something like Richfaces' < rich:ajaxValidator > not make life easier? The doc page is here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号