Skip to content

Instantly share code, notes, and snippets.

@lincolnthree
Created September 9, 2011 20:25
Show Gist options
  • Save lincolnthree/1207239 to your computer and use it in GitHub Desktop.
Save lincolnthree/1207239 to your computer and use it in GitHub Desktop.
package com.example.view;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateful;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.jboss.seam.transaction.Transactional;
import org.metawidget.forge.navigation.MenuItem;
import org.metawidget.forge.persistence.PaginationHelper;
import org.metawidget.forge.persistence.PersistenceUtil;
import com.example.domain.Customer;
@Transactional
@Named
@Stateful
@RequestScoped
public class CustomerBean extends PersistenceUtil implements MenuItem
{
private static final long serialVersionUID = 1L;
private List<Customer> list = null;
private Customer customer = new Customer();
private long id = 0;
private PaginationHelper<Customer> pagination;
public Class<?> getItemType()
{
return Customer.class;
}
public String getLiteralPath()
{
return null;
}
public String getLabel()
{
return null;
}
public void load()
{
customer = findById(Customer.class, id);
}
public String create()
{
create(customer);
return "view?faces-redirect=true&id=" + customer.getId();
}
public String delete()
{
delete(customer);
return "list?faces-redirect=true";
}
public String save()
{
save(customer);
return "view?faces-redirect=true&id=" + customer.getId();
}
public long getId()
{
return id;
}
public void setId(final long id)
{
this.id = id;
if (id > 0) {
load();
}
}
public Customer getCustomer()
{
return customer;
}
public void setCustomer(final Customer customer)
{
this.customer = customer;
}
public List<Customer> getList()
{
if (list == null) {
list = getPagination().createPageDataModel();
}
return list;
}
public void setList(final List<Customer> list)
{
this.list = list;
}
public PaginationHelper<Customer> getPagination()
{
if (pagination == null) {
pagination = new PaginationHelper<Customer>(10) {
@Override
public int getItemsCount()
{
return count(Customer.class);
}
@Override
public List<Customer> createPageDataModel()
{
return new ArrayList<Customer>(findAll(Customer.class, getPageFirstItem(), getPageSize()));
}
};
}
return pagination;
}
public void setPagination(final PaginationHelper<Customer> helper)
{
pagination = helper;
}
}
Thread [MSC service thread 1-3] (Suspended (breakpoint at line 103 in ProxyFactory))
EnterpriseProxyFactory<T>(ProxyFactory<T>).<init>(Class<?>, Set<Type>, String, Bean<?>) line: 103
EnterpriseProxyFactory<T>(ProxyFactory<T>).<init>(Class<?>, Set<Type>, Bean<?>) line: 89
EnterpriseProxyFactory<T>.<init>(Class<T>, Bean<T>) line: 48
NewSessionBean<T>(SessionBean<T>).initProxyClass() line: 263
NewSessionBean<T>(SessionBean<T>).initialize(BeanDeployerEnvironment) line: 179
BeanDeployer(AbstractBeanDeployer<E>).deploy() line: 119
BeanDeployment.deployBeans(Environment) line: 227
WeldBootstrap.deployBeans() line: 378
WeldContainer.start() line: 81
WeldService.start(StartContext) line: 89
ServiceControllerImpl$StartTask.run() line: 1765
ServiceControllerImpl$ClearTCCLTask.run() line: 2291
ThreadPoolExecutor$Worker.runTask(Runnable) line: 886
ThreadPoolExecutor$Worker.run() line: 908
ServiceContainerImpl$ServiceThread(Thread).run() line: 680
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.metawidget.forge.navigation;
/**
* Represents an item that should be displayed in scaffolded menus.
*
* @author <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*/
public interface MenuItem
{
/**
* Get the scaffolded entity type to which this item will navigate. (Can be overridden by {@link #getLiteralPath()}
*/
public Class<?> getItemType();
/**
* Get the literal view to which this item will navigate. (Overrides {@link #getItemType()})
*/
public String getLiteralPath();
/**
* Get the text to be displayed when this item is displayed.
*/
public String getLabel();
}
ejbDescriptor InternalEjbDescriptor<T> (id=421)
delegate EjbDescriptorImpl<T> (id=450)
baseName ServiceName (id=471)
ejbClass Class<T> (com.example.view.CustomerBean) (id=368)
ejbName "CustomerBean" (id=473)
localInterfaces HashSet<E> (id=474)
messageDriven false
remoteInterfaces HashSet<E> (id=475)
removeMethods Collections$UnmodifiableSet<E> (id=476)
singleton false
stateful true
stateless false
viewServices Collections$UnmodifiableMap<K,V> (id=477)
objectInterface Class<T> (org.metawidget.forge.navigation.MenuItem) (id=388)
annotations Collections$EmptyMap (id=457)
annotationType null
cachedConstructor null
classRedefinedCount 0
declaredAnnotations Collections$EmptyMap (id=457)
declaredConstructors SoftReference<T> (id=461)
declaredFields SoftReference<T> (id=463)
declaredMethods SoftReference<T> (id=465)
declaredPublicFields SoftReference<T> (id=466)
declaredPublicMethods SoftReference<T> (id=467)
enumConstantDirectory null
enumConstants null
genericInfo null
lastRedefinedCount 0
name "org.metawidget.forge.navigation.MenuItem" (id=468)
newInstanceCallerCache null
publicConstructors null
publicFields SoftReference<T> (id=469)
publicMethods SoftReference<T> (id=470)
removeMethodSignatures ArrayList<E> (id=452)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment