• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hi i am new to the JSF technology and i have faced a problem on my AppActionListener

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently using the java studio enterprise 8 plattform, jdk 1.5.0
application server 8.1 UR2 and the jsf 1.1 reference implementation.

The problem is that it gives 3 errors which are the following:
cannot import javax.faces.tree because it seems that the package is not existed in the library.

The other error is that it cannot find the symbol for the method
String actionCommand = event.getActionCommand();

The final error is that it cannot find the symbol for the method
getValueBinding(valueRef);

My packages javax.faces.event.ActionEvent and javax.faces.application.Application seem to work fine.

import java.util.Iterator;
import javax.faces.FactoryFinder;
import javax.faces.application.Application;
import javax.faces.application.ApplicationFactory;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import javax.faces.event.PhaseId;
import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.tree.Tree;
import javax.servlet.ServletContext;

public class AppActionListener implements ActionListener {
public PhaseId getPhaseId() {
return PhaseId.INVOKE_APPLICATION;
}

public void processAction(ActionEvent event) {
String actionCommand = event.getActionCommand();
if ("buy".equals(actionCommand)) {
FacesContext facesContext = FacesContext.getCurrentInstance();
String productId = (String) facesContext.getExternalContext().
getRequestParameterMap().get("productId");
ShoppingCartBean cart =
(ShoppingCartBean) getValueBinding("ShoppingCartBean").
getValue(facesContext);
ProductBean product = getDatabaseUtil(). getProductDetails(productId);
ShoppingItemBean shoppingItem = new
ShoppingItemBean(product.getId(), product.getName(), product.getPrice(), 1);
cart.addShoppingItem(shoppingItem);
}
else if ("order".equals(actionCommand)) {
// insert a record into the database
FacesContext facesContext = FacesContext.getCurrentInstance();
OrderBean order = (OrderBean)
getValueBinding("OrderBean").getValue(facesContext);
ShoppingCartBean cart = (ShoppingCartBean)
getValueBinding("ShoppingCartBean").getValue(facesContext);
getDatabaseUtil().insertOrder(order, cart);
// empty shopping cart
cart.removeShoppingItems();
}

}

private ValueBinding getValueBinding(String valueRef) {
ApplicationFactory factory =
(ApplicationFactory)FactoryFinder.
getFactory(FactoryFinder.APPLICATION_FACTORY);
Application application = factory.getApplication();
return application.getValueBinding(valueRef);
}

private DatabaseUtil getDatabaseUtil() { FacesContext
facesContext = FacesContext.getCurrentInstance();
ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
return (DatabaseUtil)
servletContext.getAttribute("DATABASE_UTIL");
}
}



If anyone knows anything about what it might be responsible for these errors please let me know.

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic