PEssoal, estou com um problema parecido com marlonmca.
eu tamebem não consigo submeter oum formulriuo;
eu uso o primefaces e as bibliotecas para funciona o woodstock pois uso o visual jsf, mas como eu precisava de ajax eu fiz essa tela com os componetes padores do jsf e o restante com o woodstock.
segue abaixo o meu .xhtml:
[code]
<?xml version="1.0" encoding="UTF-8"?>
Importar Documento
<h:form id="form1">
<h:outputLabel id="staticText2" style="left: 8px; top: 113px; position: absolute" value="Categoria:"/>
<h:commandButton
style="height: 24px; left: 340px; top: 114px; position: absolute; width: 95px"
actionListener="#{page$ImportarArquivo.enviarArquivo}"
id="buttonImportar" value="Importar"/>
<h:outputLabel id="staticText3" style="left: 18px; top: 150px; position: absolute" value="Arquivo:"/>
</h:form>
</h:body>
[/code]
[code][code]
/*
- To change this template, choose Tools | Templates
- and open the template in the editor.
*/
package br.gov.ba.ebal.sisredd.controler.page;
import br.gov.ba.ebal.sisredd.categoriadocumento.bean.CategoriaDocumentoBean;
import br.gov.ba.ebal.sisredd.categoriadocumento.bo.CategoriaDocumentoBoImplementacao;
import br.gov.ba.ebal.sisredd.categoriadocumento.bo.CategoriaDocumentoBoInterface;
import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.webui.jsf.model.SingleSelectOptionsList;
import javax.faces.FacesException;
import br.gov.ba.ebal.sisredd.controler.RequestBean;
import br.gov.ba.ebal.sisredd.controler.SessionBean;
import br.gov.ba.ebal.sisredd.controler.TipoDePermissaoUsuarioSessionBean;
import com.sun.webui.jsf.component.Upload;
import com.sun.webui.jsf.model.UploadedFile;
import com.sun.webui.jsf.component.Form;
import com.sun.webui.jsf.component.PanelGroup;
import java.util.ArrayList;
import java.util.List;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.AjaxBehaviorEvent;
import javax.faces.model.SelectItem;
import org.primefaces.component.button.Button;
/**
public class ImportarArquivo extends AbstractPageBean {
//
private Upload arquivoDeUpload = new Upload();
private DropDownCategoria dropDownCategoria = new DropDownCategoria();
private Form formularioParaCadastroDeArquivo = new Form();
private Long selecionadoCategoria;
private List listaItemCategoria;
private CategoriaDocumentoBoInterface categoriaBo = new
CategoriaDocumentoBoImplementacao();
private Button botaoInserirEditar = new Button();
/**
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
* This method is automatically generated, so any user-specified code inserted
* here is subject to being replaced.</p>
*/
private void _init() throws Exception {
// dropDownCategoria.listar();
}
// </editor-fold>
/**
* <p>Construct a new Page bean instance.</p>
*/
public ImportarArquivo() {
}
/**
* <p>Callback method that is called whenever a page is navigated to,
* either directly via a URL, or indirectly via page navigation.
* Customize this method to acquire resources that will be needed
* for event handlers and lifecycle methods, whether or not this
* page is performing post back processing.</p>
*
* <p>Note that, if the current request is a postback, the property
* values of the components do <strong>not</strong> represent any
* values submitted with this request. Instead, they represent the
* property values that were saved for this view when it was rendered.</p>
*/
@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("ImportarArquivo 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
}
/**
* <p>Callback method that is called after the component tree has been
* restored, but before any event processing takes place. This method
* will <strong>only</strong> be called on a postback request that
* is processing a form submit. Customize this method to allocate
* resources that will be required in your event handlers.</p>
*/
@Override
public void preprocess() {
}
/**
* <p>Callback method that is called just before rendering takes place.
* This method will <strong>only</strong> be called for the page that
* will actually be rendered (and not, for example, on a page that
* handled a postback and then navigated to a different page). Customize
* this method to allocate resources that will be required for rendering
* this page.</p>
*/
@Override
public void prerender() {
}
/**
* <p>Callback method that is called after rendering is completed for
* this request, if <code>init()</code> was called (regardless of whether
* or not this was the page that was actually rendered). Customize this
* method to release resources acquired in the <code>init()</code>,
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
* acquired during execution of an event handler).</p>
*/
@Override
public void destroy() {
}
public void enviarArquivo(ActionEvent evt){
UploadedFile file = arquivoDeUpload.getUploadedFile();
System.out.println("nome: "+file.getOriginalName());
System.out.println("tamanho: "+file.getSize());
}
public void criarCamposDinamicos(){
// formularioParaCadastroDeArquivo.
//this.setPainel(new HtmlPanelGrid());
// this.getPainel().setColumns(2);//
// HtmlOutputText hotTitulo = (HtmlOutputText) FacesContext.getCurrentInstance().getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);
//
// hotTitulo.setValue(“Configuração do Relatório de Pessoas”);
//
// FacesContext context = FacesContext.getCurrentInstance();
// ELContext elContext = context.getELContext();
// Application app = context.getApplication();
// ExpressionFactory expressionFactory = app.getExpressionFactory();
//
//
// ValueExpression ve = expressionFactory.createValueExpression("#{mbPessoa.filtroTeste}", String.class);
//
// //ValueBinding vb = app.createValueBinding("#{filtroTeste}");
//
// itxOperador = new HtmlInputText();
// //vb.setValue(context, vb.getValue(context));
//
// itxOperador.setValueExpression(“e”, ve);
// //itxOperador.setValueBinding(“e”, vb);
// this.getPainel().getChildren().add(itxOperador);
System.out.println("componentes dinamicoooss");
}
public void criarCampos(AjaxBehaviorEvent event) {
System.out.println(“criarCampos”);
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected RequestBean getRequestBean() {
return (RequestBean) getBean("RequestBean");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected SessionBean getSessionBean() {
return (SessionBean) getBean("SessionBean");
}
/**
* <p>Return a reference to the scoped data bean.</p>
*
* @return reference to the scoped data bean
*/
protected TipoDePermissaoUsuarioSessionBean getTipoDePermissaoUsuarioSessionBean() {
return (TipoDePermissaoUsuarioSessionBean) getBean("TipoDePermissaoUsuarioSessionBean");
}
/**
* @return the arquivoDeUpload
*/
public Upload getArquivoDeUpload() {
return arquivoDeUpload;
}
/**
* @param arquivoDeUpload the arquivoDeUpload to set
*/
public void setArquivoDeUpload(Upload arquivoDeUpload) {
this.arquivoDeUpload = arquivoDeUpload;
}
/**
* @return the dropDownCategoria
*/
public DropDownCategoria getDropDownCategoria() {
return dropDownCategoria;
}
/**
* @param dropDownCategoria the dropDownCategoria to set
*/
public void setDropDownCategoria(DropDownCategoria dropDownCategoria) {
this.dropDownCategoria = dropDownCategoria;
}
/**
* @return the formularioParaCadastroDeArquivo
*/
public Form getFormularioParaCadastroDeArquivo() {
return formularioParaCadastroDeArquivo;
}
/**
* @param formularioParaCadastroDeArquivo the formularioParaCadastroDeArquivo to set
*/
public void setFormularioParaCadastroDeArquivo(Form formularioParaCadastroDeArquivo) {
this.formularioParaCadastroDeArquivo = formularioParaCadastroDeArquivo;
}
public String cadastrarCategoriaIndexador() {
// TODO: Processe a ação. O valor de retorno é um nome de caso
// de navegação em que nulo retornará à mesma página.
return null;
}
/**
* @return the selecionadoCategoria
*/
public Long getSelecionadoCategoria() {
return selecionadoCategoria;
}
/**
* @param selecionadoCategoria the selecionadoCategoria to set
*/
public void setSelecionadoCategoria(Long selecionadoCategoria) {
System.out.println("setSelecionadoCategoria");
this.selecionadoCategoria = selecionadoCategoria;
}
/**
* @return the listaItemCategoria
*/
public List<SelectItem> getListaItemCategoria() {
ArrayList<CategoriaDocumentoBean> categoriaDocumento =categoriaBo.listarCategoriaDocumento( );
ArrayList<SelectItem> listaItemCategoria = new ArrayList<SelectItem>();
for(CategoriaDocumentoBean categoria :categoriaDocumento){
SelectItem item = new SelectItem(categoria.getIdCategoriaDocumento(), categoria.getDescricao());
listaItemCategoria.add(item);
}
return listaItemCategoria;
}
/**
* @param listaItemCategoria the listaItemCategoria to set
*/
public void setListaItemCategoria(List<SelectItem> listaItemCategoria) {
this.listaItemCategoria = listaItemCategoria;
}
/**
* @param categoriaBo the categoriaBo to set
*/
public void setCategoriaBo(CategoriaDocumentoBoInterface categoriaBo) {
this.categoriaBo = categoriaBo;
}
/**
* @return the botaoInserirEditar
*/
public Button getBotaoInserirEditar() {
return botaoInserirEditar;
}
/**
* @param botaoInserirEditar the botaoInserirEditar to set
*/
public void setBotaoInserirEditar(Button botaoInserirEditar) {
this.botaoInserirEditar = botaoInserirEditar;
}
}[/code][/code]
e aparece a seguinte mensagem:
21/03/2012 12:36:25 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:161)
at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1427)
at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1202)
at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1217)
at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1217)
at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1217)
at javax.faces.component.UIViewRoot.processRestoreState(UIViewRoot.java:865)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:197)
at javax.faces.application.StateManagerWrapper.restoreView(StateManagerWrapper.java:178)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:131)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:430)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:143)
at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:348)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:199)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:110)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:267)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Thread.java:662)