Pessoal, tava lendo o JSF in Action quando o autor fez um exemplo simples.
Estou usando o plugin pra JSF Exadel.
Só que na hora de fazer uma classe que usa um Listener JSF o eclipse não está conseguindo fazer os imports necessários. O estranho é que o Exadel já deveria ter reconhecimento as bibliotecas necessárias. Só que estou com receio de o código já estar obsoleto e portanto não é mais reconhecido
Ta aí o exemplo do Bean
package org.jia.hello;
import javax.faces.application.Application;
import javax.faces.component.html.HtmlOutputText;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import java.util.List;
public class HelloBean
{
private int numControls;
private HtmlPanelGrid controlPanel;
public int getNumControls()
{
return numControls;
}
public void setNumControls(int numControls)
{
this.numControls = numControls;
}
public HtmlPanelGrid getControlPanel()
{
return controlPanel;
}
public void setControlPanel(HtmlPanelGrid controlPanel)
{
this.controlPanel = controlPanel;
}
public void addControls(ActionEvent actionEvent)
{
Application application = FacesContext.getCurrentInstance().getApplication();
List children = controlPanel.getChildren();
children.clear();
for (int count = 0; count < numControls; count++)
{
HtmlOutputText output = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
output.setValue(" " + count + " ");
output.setStyle("color: blue");
children.add(output);
}
}
public String goodbye()
{
return "success";
}
}
E da JSP
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title></title>
</head>
<body>
<f:view>
<h:form id="welcomeForm">
<h:outputText value="Welcome to JSF" id="welcomeOutput"/>
<p><h:message for="helloInput" id="errors" /></p>
<p><h:outputLabel><h:outputText value="Digite um valor" /></h:outputLabel></p>
<p>
<h:inputText id="helloInput" value="#{helloBean.numControls}">
<f:validateLength minimum="1" maximum="500"/>
</h:inputText>
</p>
<p>
<h:panelGrid id="controlPanel" binding="#{helloBean.controlPanel}" columns="20" />
</p>
<h:commandButton actionListener="#{helloBean.addControl}" value="Redisplay" type="submit" />
<h:commandButton action="#{helloBean.goodBye}" value="Say GoodBye" type="submit" />
</h:form>
</f:view>
</body>
</html>
Valeu pela ajuda!