If you have a validation error on the current page, then no action will
be invoked. That's a fundamental part of JSF: actions only get executed
after the backing bean properties have been updated. However properties
cannot be updated if the user data is not valid! So if any field in the
page is invalid then *no* properties get updated in the backing bean and
*no* actions get executed; the page is simply re-rendered (with
validation messages displayed if you have an h:messages tag).
If you really want an action to be executed even when the current page
has invalid data then you need to mark that action with
"immediate=true". Note, however, that if you do that then none of the
user data (ie input fields on that page) will be stored into the backing
bean.
Regards,
Simon
[EMAIL PROTECTED] wrote:
Simon Kitching пишет:
What do you mean by "stops working"?
I mean, when i pressing it, page simply reloads while backing bean
method not invoked.
And where is this "category" variable referenced in the delete method
declared? Why is it not null?
Oh, yes, here is all about category:
// members declaration:
private Category category;
private boolean editmode;
// Constructor: category initialized with empty domain object
public CategoryBean() {
category = new Category();
category.setParent(new Category());
}
[EMAIL PROTECTED] wrote:
Thank you for your answer.
Where should i else start looking ?
I think that i checked everything, the form finally shrinked down and
now it really simple:
<t:saveState value="#{CategoryBean.editmode}"/>
<h:form>
<h:inputText id="name" value="#{CategoryBean.category.name}"
required="true" maxlength="255" />
<h:message for="name" style="color: red" />
<h:commandLink action="#{CategoryBean.submit}" value="Save"
styleClass="cl" />
<h:commandLink action="#{CategoryBean.delete}" value="Delete"
styleClass="dl" rendered="#{CategoryBean.editmode}" />
</h:form>
and commandLink actions:
public String delete() throws SQLException {
CategoryDAO dao = SqlMapDAOFactory.getCategoryDAO();
int deleted = dao.deleteById(category.getId().intValue());
return "category_list";
}
public String submit() throws SQLException {
CategoryDAO dao = SqlMapDAOFactory.getCategoryDAO();
dao.update(category);
return "category_list";
}
But "Delete" button stops working if "Submit" was pressed before and
validation error occurs because of: required="true" in text field.
Everything looks pretty bulletproof :\