Please I am missing a point here. How can I handle a request with multiple outcomes in JSF 2.0 using the implicit navigation For example using the explicit navigation I can write the following:
<navigation-rule>
<from-view-id>/products/DeleteItem.xhtml</from-view-id>
<navigation-case>
<from-outcome>itemDeleted</from-outcome>
<to-view-id>/products/Success.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>itemNotExist</from-outcome>
<to-view-id>/products/Failure.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
However How can I achieve the same thing with the implicit navigation, I have tried the following :
<h:link value="Delete a Product" outcome="Success" />
only one case is mentioned but I want to forward either to Success.xhtml or Failure.xhtml depending on the outcome.
Here a some additional information for the implicit navigation.
Managed bean:
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class DeletionBean {
@EJB
private app.session.ProductFacade ejbProductFacade;
private int id=0;
public DeletionBean() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String deleteProduct(){
String result;
result=ejbProductFacade.deleteItem(id);
if(result.equals("success"))
{
status="Successfully performed"; //msg to be shown
return "product/DeleteItem";
}
else return "product/Failure";
}
}
Form:
<h:form>
<table border="1" width="5" cellspacing="1" cellpadding="1">
<tr>
<td> Product ID </td>
<td>
<h:inputText id="pid" size="10" value="#{deletionBean.id}" title="Product ID" required="true" requiredMessage="Product ID required"/>
</td>
</tr>
<tr>
<td colspan="2">
<h:commandLink value="Delete" action="#{deletionBean.deleteProduct}" />
</td>
</tr>
</table>
</h:form>
Current error message:
Unable to find matching navigation case with from-view-id '/product/DeleteItem.xhtml' for action '#{deletionBean.deleteProduct}' with outcome 'product/Failure'