[JBoss Seam] - Re: setActionListener(???); with iceFaces
by PatrickMadden
Here is what I ended up doing to get it to work - right now I do get calls on the backend when I click a menu. After spelunking many forums it was mentioned that you should just use a regular managed bean and sure enough it worked for me.
Here is my backing bean:
| package com.clooster.web.ejb.session;
|
| import java.util.ArrayList;
| import java.util.List;
|
| import javax.ejb.Stateless;
| import javax.faces.component.UIViewRoot;
| import javax.faces.context.FacesContext;
| import javax.faces.el.EvaluationException;
| import javax.faces.el.MethodBinding;
| import javax.faces.el.MethodNotFoundException;
| //import javax.faces.event.AbortProcessingException;
| import javax.faces.event.ActionEvent;
| //import javax.faces.event.ActionListener;
|
| import org.hibernate.validator.Valid;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.log.Log;
| import org.jboss.seam.ScopeType;
|
| import com.clooster.web.ejb.entity.ClUsers;
| import com.icesoft.faces.component.menubar.MenuItemBase;
| import com.icesoft.faces.component.menubar.MenuItem;
| //import com.icesoft.faces.component.menubar.MenuItemSeparator;
|
| //@Stateless
| //@Name("flashMenu")
| //(a)Scope(ScopeType.SESSION)
| //@LoggedIn
| public class FlashSearchMenuBean implements FlashSearchMenu
| {
| //@Logger
| //Log log;
|
| //@In
| //private FacesContext facesContext;
|
| //@In @Valid
| //private ClUsers user;
|
| // records which menu item fired the event
| private String actionFired;
|
| // records the param value for the menu item which fired the event
| private String param;
|
| // orientation of the menubar ("horizontal" or "vertical")
| private String orientation = "horizontal";
|
| private List<MenuItemBase> menu = null;
|
| /**
| *
| *
| */
| public FlashSearchMenuBean()
| {
| System.out.println("FlashSearchMenuBean() Constructor");
| }
|
| public void actionListener(ActionEvent e)
| {
| System.out.println("FlashSearchMenuBean action event" + e.toString());
| }
|
| //add additional action methods
|
| /**
| * Get the orientation of the menu ("horizontal" or "vertical")
| *
| * @return the orientation of the menu
| */
| public String getOrientation() {
| return orientation;
| }
|
| /**
| * Set the orientation of the menu ("horizontal" or "vertical").
| *
| * @param orientation the new orientation of the menu
| */
| public void setOrientation(String orientation) {
| this.orientation = orientation;
| }
|
| /**
| * Get the param value for the menu item which fired the event.
| *
| * @return the param value
| */
| public String getParam() {
| return param;
| }
|
| /**
| * Set the param value.
| */
| public void setParam(String param) {
| this.param = param;
| }
|
| /**
| * Get the modified ID of the fired action.
| *
| * @return the modified ID
| */
| public String getActionFired() {
| return actionFired;
| }
|
| public String switchOrientation()
| {
| if (this.getOrientation().equals("horizontal"))
| this.setOrientation("vertical");
| else
| this.setOrientation("horizontal");
|
| return "success";
| }
|
| public List<MenuItemBase> getMenuItems()
| {
| if (this.menu == null)
| {
| FacesContext context = FacesContext.getCurrentInstance();
| UIViewRoot uiViewRoot = context.getViewRoot();
|
| menu = new ArrayList<MenuItemBase>();
|
| MenuItem fileMenu = new MenuItem();
| fileMenu.setValue("File");
| fileMenu.setId(uiViewRoot.createUniqueId());
|
| MenuItem newMenu = new MenuItem();
| newMenu.setValue("New");
| newMenu.setId(uiViewRoot.createUniqueId());
|
| newMenu.setIcon("img/menu/new.gif");
| newMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| MenuItem closeMenu = new MenuItem();
| closeMenu.setValue("Close");
| closeMenu.setId(uiViewRoot.createUniqueId());
| //newMenu.setIcon("/img/menu/new.gif");
| closeMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| MenuItem saveMenu = new MenuItem();
| saveMenu.setValue("Save");
| saveMenu.setId(uiViewRoot.createUniqueId());
| saveMenu.setIcon("img/menu/save.gif");
| saveMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| MenuItem printMenu = new MenuItem();
| printMenu.setValue("Print");
| printMenu.setId(uiViewRoot.createUniqueId());
| printMenu.setIcon("img/menu/print.gif");
| printMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| fileMenu.getChildren().add(newMenu);
| fileMenu.getChildren().add(closeMenu);
| fileMenu.getChildren().add(saveMenu);
| fileMenu.getChildren().add(printMenu);
|
| MenuItem viewMenu = new MenuItem();
| viewMenu.setValue("View");
| viewMenu.setId(uiViewRoot.createUniqueId());
|
| MenuItem zoomInMenu = new MenuItem();
| zoomInMenu.setValue("Zoom In");
| zoomInMenu.setId(uiViewRoot.createUniqueId());
| zoomInMenu.setIcon("img/menu/zoomin.gif");
| zoomInMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| MenuItem zoomOutMenu = new MenuItem();
| zoomOutMenu.setValue("Zoom Out");
| zoomOutMenu.setId(uiViewRoot.createUniqueId());
| zoomOutMenu.setIcon("img/menu/zoomout.gif");
| zoomOutMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| MenuItem zoomActualSizeMenu = new MenuItem();
| zoomActualSizeMenu.setValue("Actual Size");
| zoomActualSizeMenu.setId(uiViewRoot.createUniqueId());
| zoomActualSizeMenu.setIcon("img/menu/actualsize.gif");
| zoomActualSizeMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| MenuItem zoomFitInWindowMenu = new MenuItem();
| zoomFitInWindowMenu.setValue("Fit In Window");
| zoomFitInWindowMenu.setId(uiViewRoot.createUniqueId());
| zoomFitInWindowMenu.setIcon("img/menu/fitinwindow.gif");
| zoomFitInWindowMenu.setActionListener(this.createMethodBinding("actionListener"));
|
| viewMenu.getChildren().add(zoomInMenu);
| viewMenu.getChildren().add(zoomOutMenu);
| viewMenu.getChildren().add(zoomActualSizeMenu);
| viewMenu.getChildren().add(zoomFitInWindowMenu);
|
| menu.add(fileMenu);
| //menu.add(new MenuItemSeparator());
| menu.add(viewMenu);
| }
| return menu;
| }
|
| MethodBinding createMethodBinding(String method)
| {
| Class[] args = {ActionEvent.class};
| MethodBinding mb = FacesContext.getCurrentInstance().getApplication().createMethodBinding("#{flashMenu." + method + "}", args);
| return mb;
|
| }
| }
|
I apologize for some of the commented out code but I was just trying to get it to work.
Next is my portion of the faces-config.xml
| <managed-bean>
| <managed-bean-name>flashMenu</managed-bean-name>
| <managed-bean-class>com.clooster.web.ejb.session.FlashSearchMenuBean</managed-bean-class>
| <managed-bean-scope>session</managed-bean-scope>
| </managed-bean>
|
Hope this helps,
PVM
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997828#3997828
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997828
19 years, 3 months
[JBoss Seam] - Re: Using Seam gem for tomcat with and without embedded ejb3
by norman.richards@jboss.com
I think I'd always rather run an app in a proper app server than in a simple web container. There are so many more deployment and management options, and applications are so much easier to work with in the JBoss. Tomcat standalone feels rather clunky and confined to me. It's like trying to use a windows shell when you are used to using a UNIX shell. You can still get things done, but it's just not a very good experience. Even if I only needed/wanted tomcat features, I'd still prefer to run a bare tomcat profile in JBoss rather than in tomcat standalone. (the installer do that now, so it's not a pain like it used to be)
That being said, hopefully we'll be able to support more deployment options in seam-gen in the future. If it is particularly important to you, maybe you will want to chip and help out? :)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997822#3997822
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997822
19 years, 3 months
[EJB 3.0] - Re: Service Beans in Embeddable EJB 3.0?
by jazir1979
Hi there,
If your EJBs are being started you will see it in your logs, something similar to what I've got here:
| DEBUG 03-01 15:00:33,895 (Ejb3AnnotationHandler.java:getContainers:158) -found EJB3: ejbName=LookupActionBean, class=LookupActionBean, type=STATELESS
| DEBUG 03-01 15:00:33,906 (ProxyDeployer.java:initializeRemoteBindingMetadata:131) -no declared remote bindings for : LookupActionBean
| DEBUG 03-01 15:00:33,925 (Ejb3DescriptorHandler.java:addClassAnnotation:1686) -adding class annotation org.jboss.annotation.internal.DefaultInterceptorMarker to LookupServiceBean org.jboss.annotation.internal.DefaultInterceptorMarkerImpl@2d95b3
| DEBUG 03-01 15:00:33,926 (Ejb3DescriptorHandler.java:addClassAnnotation:1688) -adding class annotation org.jboss.annotation.internal.DefaultInterceptorMarker to LookupServiceBean org.jboss.annotation.internal.DefaultInterceptorMarkerImpl@2d95b3
| DEBUG 03-01 15:00:33,928 (Ejb3DescriptorHandler.java:addClassAnnotation:1686) -adding class annotation javax.annotation.security.DeclareRoles to LookupServiceBean org.jboss.ejb.DeclareRolesImpl@bf5555
| DEBUG 03-01 15:00:33,928 (Ejb3DescriptorHandler.java:addClassAnnotation:1688) -adding class annotation javax.annotation.security.DeclareRoles to LookupServiceBean org.jboss.ejb.DeclareRolesImpl@bf5555
|
When I have the above bean, I can look it up from a unit test as:
| bean = (LookupAction) ctx.lookup("LookupActionBean/local");
|
Check that your unit tests run with the following jndi.properties in the classpath, or specified when you get your initial context:
| java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
| java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3997815#3997815
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3997815
19 years, 3 months