aspose file tools*
The moose likes JSF and the fly likes errors's management Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "errors Watch "errors New topic
Author

errors's management

rosaria italia
Greenhorn

Joined: May 15, 2006
Posts: 28
Hi, I would to use <from-outcome> in faces-config.xml for errors's management:
<navigation-rule>
<description>Pagina di errore</description>
<navigation-case>
<from-outcome>errore</from-outcome>
<to-view-id>/errore.jsp</to-view-id>
</navigation-case>
</navigation-rule>

I thought to use a "return" in my class that manage event:

public String deleteUser(String id, Map session) throws NamingException, SQLException,Errore{
try{
...
String sql="DELETE FROM Users WHERE ID="+id;

return "";
}catch(Exception e)
{ return "errore";
}
.....
But, doesn't work it!
How do I do?
Wendell Miranda
Greenhorn

Joined: May 30, 2006
Posts: 11
try it:
String redirect = "";


int exc = ps.executeUpdate();

if( exc != 0 ){
return redirect = "success";
}else{
return redirect = "failure";
}

And into your faces-config.xml adding CASES to "success" and "failure" okays?
rosaria italia
Greenhorn

Joined: May 15, 2006
Posts: 28
Hello, I have tried, but "case" into my faces-config.xml doesn't execute it! Help me. This is my code:
faces-config.xml:
<navigation-rule> <from-view-id>*</from-view-id>
<navigation-case><from-outcome>failure</from-outcome>
<to-view-id>/error.jsp</to-view-id></navigation-case></navigation-rule>
<navigation-rule> <from-view-id>*</from-view-id>
<navigation-case><from-outcome>success</from-outcome>
<to-view-id>/success.jsp</to-view-id></navigation-case></navigation-rule>

User.java
...
public String deleteUser(ActionEvent event) {
...
String s=ut.deleteUtenteToDB(id,session);
System.out.println("s= "+s);
return s;}

UserD.java
...
public String deleteUtenteToDB(String id, Map session) {
...
if( exc != 0 ){
return redirect = "success";
}else{
return redirect = "failure";
}
....

When I print variable "s", it is correct value (failure or success), but don't show page success.jsp or error.jsp.

Thanks
rosaria italia
Greenhorn

Joined: May 15, 2006
Posts: 28
Sorry, but I have still this problem. In my page jsp, I use this code:
<h:commandLink id="Prova"
action="#{utenteBean.deleteUtente}" >
<h utputText value="Prova" />
<f aram id="provaId"
name="id"
value="#{utente.id}" />
</h:commandLink>
In my page java e faces-config.xml code is that one I have written in previous replies.

This is error :
javax.servlet.ServletException: #{utenteBean.deleteUtente}: javax.faces.el.MethodNotFoundException: deleteUtente: it.istream.jsf.Utente.deleteUtente()
javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)....

Could you help me, please?
Jamie Williams
Ranch Hand

Joined: Mar 31, 2006
Posts: 70
Your problem is with your method naming. What classes are utente and utenteBean? You are calling utenteBean.deleteUtente, but you haven't listed this method in your post. Try changing:



to:

rosaria italia
Greenhorn

Joined: May 15, 2006
Posts: 28
I have resolved... Problem was that I use a ActionEvent...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: errors's management