Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

errors's management

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have resolved... Problem was that I use a ActionEvent...
 
Our first order of business must be this tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic