Elementos compartidos de ics

miércoles, 1 de octubre de 2008

trap errors with httphandlers equivalent

if you want to do the same error trapping that in asp .net but in jsp...



http://scriptlandia.blogspot.com/2006/06/how-to-handle-jsp-error-page.html

http://www.itjungle.com/mpo/mpo031402-story03.html

Note: in visual web netbeans 6.1, in the jsp you should do this way....

miércoles, 24 de septiembre de 2008

response.redirect

 try {

            ExternalContext e = FacesContext.getCurrentInstance().getExternalContext();
            e.redirect(e.encodeResourceURL(e.getRequestContextPath() + "/faces/edit_project.jsp"));

        } catch (IOException ex) {
            Logger.getLogger(list_project.class.getName()).log(Level.SEVERE, null, ex);
        }

martes, 23 de septiembre de 2008

netbeans 6.1 binding attributes

original question in the forum:
I finally needed to create a simple web page in Java and I figured JSF looks like a good fit since I'm used to ASP.NET. So I created my page and to my surprise I wasn't able to access any of the GUI elements. So I went to the tutorial thinking I must be doing something wrong... but same story here.

my reply:
from netbeans 6.1 you have to do some things to see the controls, you will have to select them and then with right click - add binding atribute...


http://wiki.netbeans.org/OnDemandBindingAttribute

viernes, 12 de septiembre de 2008

how to get request parameters in visual web project (netbeans)

the name of the fields can be like " form1:calendar1_field" or "form1:dropDown1_list", so ive created a function to make it simple


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package classes;

// get information context -request parameters
import java.util.Enumeration;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
*
* @author Administrador
*/
public class util {


// returns the value stored in request("parameter")
public static String recko(String parameter) {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
String controlName = request.getParameter("form1:textField1_field");

// iterate the collection
Enumeration e = request.getParameterNames();

while (e.hasMoreElements()) {
String s_clave = e.nextElement().toString();
String s_aux = request.getParameter(s_clave);
if (s_clave.indexOf(parameter + '_') != -1) {
return s_aux;
}
}
return "";
}
}


to use it (for example get the value in textField1.

String cadena=util.recko("textField1");