File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Hi i am new to the JSF technology and i have faced a problem on my AppActionListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Hi i am new to the JSF technology and i have faced a problem on my AppActionListener" Watch "Hi i am new to the JSF technology and i have faced a problem on my AppActionListener" New topic
Author

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

anbu alagan
Greenhorn

Joined: Mar 03, 2006
Posts: 3
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hi i am new to the JSF technology and i have faced a problem on my AppActionListener
 
Similar Threads
Cookie maxAge problem
backBean add to list Problem
New JSF/Portlet Developer Help needed
Has anybody successfully run the Virtual Trainer application in "JSF Complete Reference"?
variable to initialize not working?