How to skip Bean Validation on inputs when pressing specific button

97 views Asked by At

I add/delete rows dynamically using a datatable. I have a problem with deleting rows. In fact, I want to delete a row without validating the fields. At the same time, I need my model updated, so using immediate="true" is inadequate (http://blog.jerryorr.com/2012/01/jsf-and-immediate-attribute-command.html). This is my code:

<h:dataTable id="tbl" value="#{bean.list}" var="l" style="width: 100%;">
    <h:column>
        <h:panelGrid styleClass="dr-pnl" style="width: 100%;">
            <h:outputLabel for="name">Name</h:outputLabel>
            <h:inputText id="name" value="#{l.name}"></h:inputText>
             <h:commandButton id="delete" value="Delete">
                <f:ajax listener="#{bean.delete(l)}" execute="@form" render="@form" />
            </h:commandButton>
        </h:panelGrid>
    </h:column>
    <f:facet name="footer">
        <h:commandButton id="add" value="Add">
            <f:ajax listener="#{bean.add}" execute="@form" render="tbl" immediate="true" />
        </h:commandButton>
    </f:facet>
</h:dataTable>

To get around this problem, I thought that I should use Javascript to delete the content of my fields before calling the method bean.delete(l). How can I do that?

Thanks for your help!

0

There are 0 answers