java con netbeans 6.1
Publicado por saachp (1 intervención) el 24/11/2008 19:43:44
yo estoy haciendo una aplicacion web, pero necesito agregar registros a la based e datos
utilizando los dataprovider, utilizo textfield donde agrego los datos y los tengo que capturar el dato, utilizo un boton guardar para almacenar los datos.
utilizo el netbeans
ejemplo:
nombre: textfield1
edad: textfield 2
.....asi sucesivamente.
lo que pasa que nose como agregara los datos a la base dedatos.de acuerdo a la estructura que da netbeans 6.1.
package juridicosct;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.sql.rowset.CachedRowSetXImpl;
import com.sun.webui.jsf.model.DefaultTableDataProvider;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import javax.faces.FacesException;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @author cchivard
*/
public class usuario_operaciones extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
private void _init() throws Exception {
cuentas_usuariosDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{usuario_operaciones.cuentas_usuariosRowSet}"));
cuentas_usuariosRowSet.setDataSourceName("java:comp/env/jdbc/sctjuridico_MySQL");
cuentas_usuariosRowSet.setCommand("SELECT * FROM cuentas_usuarios");
cuentas_usuariosRowSet.setTableName("cuentas_usuarios");
}
private SingleSelectOptionsList dropDown1DefaultOptions = new SingleSelectOptionsList();
public SingleSelectOptionsList getDropDown1DefaultOptions() {
return dropDown1DefaultOptions;
}
public void setDropDown1DefaultOptions(SingleSelectOptionsList ssol) {
this.dropDown1DefaultOptions = ssol;
}
private SingleSelectOptionsList dropDown2DefaultOptions = new SingleSelectOptionsList();
public SingleSelectOptionsList getDropDown2DefaultOptions() {
return dropDown2DefaultOptions;
}
public void setDropDown2DefaultOptions(SingleSelectOptionsList ssol) {
this.dropDown2DefaultOptions = ssol;
}
private CachedRowSetDataProvider cuentas_usuariosDataProvider = new CachedRowSetDataProvider();
public CachedRowSetDataProvider getCuentas_usuariosDataProvider() {
return cuentas_usuariosDataProvider;
}
public void setCuentas_usuariosDataProvider(CachedRowSetDataProvider crsdp) {
this.cuentas_usuariosDataProvider = crsdp;
}
private CachedRowSetXImpl cuentas_usuariosRowSet = new CachedRowSetXImpl();
public CachedRowSetXImpl getCuentas_usuariosRowSet() {
return cuentas_usuariosRowSet;
}
public void setCuentas_usuariosRowSet(CachedRowSetXImpl crsxi) {
this.cuentas_usuariosRowSet = crsxi;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public usuario_operaciones() {
}
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("usuario_operaciones Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/ @Override
public void preprocess() {
}
@Override
public void prerender() {
}
@Override
public void destroy() {
cuentas_usuariosDataProvider.close();
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1) getBean("RequestBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1) getBean("SessionBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
public String hyperlink1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
public String button1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
}
utilizando los dataprovider, utilizo textfield donde agrego los datos y los tengo que capturar el dato, utilizo un boton guardar para almacenar los datos.
utilizo el netbeans
ejemplo:
nombre: textfield1
edad: textfield 2
.....asi sucesivamente.
lo que pasa que nose como agregara los datos a la base dedatos.de acuerdo a la estructura que da netbeans 6.1.
package juridicosct;
import com.sun.data.provider.impl.CachedRowSetDataProvider;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.sql.rowset.CachedRowSetXImpl;
import com.sun.webui.jsf.model.DefaultTableDataProvider;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import javax.faces.FacesException;
/**
* <p>Page bean that corresponds to a similarly named JSP page. This
* class contains component definitions (and initialization code) for
* all components that you have defined on this page, as well as
* lifecycle methods and event handlers where you may add behavior
* to respond to incoming events.</p>
*
* @author cchivard
*/
public class usuario_operaciones extends AbstractPageBean {
// <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
private void _init() throws Exception {
cuentas_usuariosDataProvider.setCachedRowSet((javax.sql.rowset.CachedRowSet) getValue("#{usuario_operaciones.cuentas_usuariosRowSet}"));
cuentas_usuariosRowSet.setDataSourceName("java:comp/env/jdbc/sctjuridico_MySQL");
cuentas_usuariosRowSet.setCommand("SELECT * FROM cuentas_usuarios");
cuentas_usuariosRowSet.setTableName("cuentas_usuarios");
}
private SingleSelectOptionsList dropDown1DefaultOptions = new SingleSelectOptionsList();
public SingleSelectOptionsList getDropDown1DefaultOptions() {
return dropDown1DefaultOptions;
}
public void setDropDown1DefaultOptions(SingleSelectOptionsList ssol) {
this.dropDown1DefaultOptions = ssol;
}
private SingleSelectOptionsList dropDown2DefaultOptions = new SingleSelectOptionsList();
public SingleSelectOptionsList getDropDown2DefaultOptions() {
return dropDown2DefaultOptions;
}
public void setDropDown2DefaultOptions(SingleSelectOptionsList ssol) {
this.dropDown2DefaultOptions = ssol;
}
private CachedRowSetDataProvider cuentas_usuariosDataProvider = new CachedRowSetDataProvider();
public CachedRowSetDataProvider getCuentas_usuariosDataProvider() {
return cuentas_usuariosDataProvider;
}
public void setCuentas_usuariosDataProvider(CachedRowSetDataProvider crsdp) {
this.cuentas_usuariosDataProvider = crsdp;
}
private CachedRowSetXImpl cuentas_usuariosRowSet = new CachedRowSetXImpl();
public CachedRowSetXImpl getCuentas_usuariosRowSet() {
return cuentas_usuariosRowSet;
}
public void setCuentas_usuariosRowSet(CachedRowSetXImpl crsxi) {
this.cuentas_usuariosRowSet = crsxi;
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public usuario_operaciones() {
}
@Override
public void init() {
// Perform initializations inherited from our superclass
super.init();
// Perform application initialization that must complete
// *before* managed components are initialized
// TODO - add your own initialiation code here
// <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
// Initialize automatically managed components
// *Note* - this logic should NOT be modified
try {
_init();
} catch (Exception e) {
log("usuario_operaciones Initialization Failure", e);
throw e instanceof FacesException ? (FacesException) e: new FacesException(e);
}
// </editor-fold>
// Perform application initialization that must complete
// *after* managed components are initialized
// TODO - add your own initialization code here
}
/ @Override
public void preprocess() {
}
@Override
public void prerender() {
}
@Override
public void destroy() {
cuentas_usuariosDataProvider.close();
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean1 getRequestBean1() {
return (RequestBean1) getBean("RequestBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected SessionBean1 getSessionBean1() {
return (SessionBean1) getBean("SessionBean1");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected ApplicationBean1 getApplicationBean1() {
return (ApplicationBean1) getBean("ApplicationBean1");
}
public String hyperlink1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
public String button1_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
return null;
}
}
Valora esta pregunta


0