Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errors's management

 
rosaria italia
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have resolved... Problem was that I use a ActionEvent...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic