vi posto il codice della pagina jsp:
codice:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Creazione Categoria</title>
</head>
<body>
<h2>Crea Categoria</h2>
<form name="cercaCategorie" action="GestoreInterfaccia" method="POST">
<input type="hidden" name="azione" value="mostraElencoCategoria" />
<input type="submit" value="carica" class="button"/>
</form>
<form action="ControllerLogic" name="form_cat" method="post">
<input type="hidden" name="choice" value="creaCategoria"/>
<fieldset>
<legend>Dati Categoria</legend>
<table id="reg-table-login">
<tr><th>Categoria</th><td><input type="text" name="categoria"/></td></tr>
<tr><th>Codice Categoria</th><td><input type="text" name="cod_cat"/></td></tr>
<tr><th>Categoria Principale
<select name="categoriaPrincipale" >
<%
ejb.GestoreCategoriaBeanRemote gestoreCategoria = null ;
java.util.List<ejb.Categoria> elencoCat= null;
elencoCat = gestoreCategoria.mostraElenco();
if (elencoCat != null) {
for (ejb.Categoria cat : elencoCat) {
%>
<option value=<%=cat.getCod_cat()%> > <%=cat.getNome_cat()%> </option>
<%}
} else {
%>
<option value="1"> root</option>
<% }%>
</select>
</th><td>
</table>
</fieldset>
Tutti i dati contrassegnati con * sono obbligatori</p>
<input type="submit" name="invio" value="Entra"/>
<input type="reset" name="annulla" value="Annulla"/>
</form>
</body>
</html>
e del metodo java remote richiamato:
codice:
package ejb;
import java.util.List;
import javax.ejb.Remote;
/**
*
* @author alessandro
*/
@Remote
public interface GestoreCategoriaBeanRemote {
public Categoria crea(String nome, int codCat, int padreCat);
public List mostraElenco();
}
e del facade corriposndente:
codice:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ejb;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
/**
*
* @author alessandro
*/
@Stateless
public class GestoreCategoriaBean implements GestoreCategoriaBeanRemote {
// Add business logic below. (Right-click in editor and choose
// "EJB Methods > Add Business Method" or "Web Service > Add Operation")
@EJB
private CategoriaFacadeRemote categoriaFacade;
/** Creates a new instance of GestoreCategoriaBean */
public GestoreCategoriaBean() {
}
public Categoria crea(String nomeCat, int codCat, int padreCat) {
if (!categoriaFacade.findSome(codCat).isEmpty()) {
return null;
}
Categoria cat = new Categoria();
cat.setNome_cat(nomeCat);
cat.setCod_cat(codCat);
cat.setPadre_cat(padreCat);
categoriaFacade.create(cat);
return cat;
}
public List mostraElenco() {
return categoriaFacade.findAll();
}
}
gli altri metodi richiamati funzionano tutti perchè già testati per la creazione dell'utente..
grazie ancora...