java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy7.proxyClassLookup() - appium

public Login(AndroidDriver<AndroidElement> driver)
{
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
#AndroidFindBy(xpath="//android.widget.Button[#text='NONE OF THE ABOVE']")
private MobileElement None;
public MobileElement clickNone(){
return None;

Related

Appium - PageFactory initElements is not working

I have this Class as my page object:
public class LaunchPageObject {
private AppiumDriver<AndroidElement> driver;
public LaunchPageObject() {
}
public LaunchPageObject(AppiumDriver<AndroidElement> driver) {
this.driver=driver;
PageFactory.initElements(new AppiumFieldDecorator(this.driver), this);
}
public void Click_SigninNow() {
lnk_SigninNow.click();
}
#AndroidFindBy(xpath="//android.widget.Button[#text='LOGIN WITH FACEBOOK']")
MobileElement btn_SignupWithEmail;
#AndroidFindBy(xpath="//android.widget.Button[#text='SIGN UP WITH EMAIL']")
MobileElement btn_LoginWithFacebook;
#AndroidFindBy(xpath="//android.widget.TextView[#text='Sign in now']")
MobileElement lnk_SigninNow;
}
and I have this class as my test case class:
public class LaunchPageTest extends Android {
#Test
public void Click_SigninNow() throws MalformedURLException {
LaunchPageObject lp = new LaunchPageObject(setDriver());
lp.Click_SigninNow();
}
}
I have this error log:
FAILED: Click_SigninNow
java.lang.ExceptionInInitializerError
at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:52)
at io.appium.java_client.pagefactory.utils.ProxyFactory.getEnhancedProxy(ProxyFactory.java:33)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.proxyForAnElement(AppiumFieldDecorator.java:217)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.access$0(AppiumFieldDecorator.java:215)
at io.appium.java_client.pagefactory.AppiumFieldDecorator$1.proxyForLocator(AppiumFieldDecorator.java:107)
at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:62)
at io.appium.java_client.pagefactory.AppiumFieldDecorator.decorate(AppiumFieldDecorator.java:155)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
at POM.LaunchPageObject.(LaunchPageObject.java:35)
at TestCases.LaunchPageTest.Click_SigninNow(LaunchPageTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
The test opens the app but is not able to click the element. Any idea what is happening here?
Keep your page object and test classes like below
public class LaunchPageObject {
#AndroidFindBy(xpath="//android.widget.Button[#text='LOGIN WITH FACEBOOK']")
MobileElement btn_SignupWithEmail;
#AndroidFindBy(xpath="//android.widget.Button[#text='SIGN UP WITH EMAIL']")
MobileElement btn_LoginWithFacebook;
#AndroidFindBy(xpath="//android.widget.TextView[#text='Sign in now']")
MobileElement lnk_SigninNow;
public void click_SigninNow() {
lnk_SigninNow.click();
}
}
public class LaunchPageTest extends Android {
LaunchPageObject lp = PageFactory.initElements(getDriver(), LaunchPageObject.class);
#Test
public void Click_SigninNow() throws MalformedURLException {
lp.Click_SigninNow();
}
}

Shopping Cart does not display updated info

I'm using WildFly 9.0 and IntelliJ 14 Ultimate
I can add items to the cart- and they can be viewed using a PrimeFaces data table on ViewCart.xhtml
There is a button to delete each cart item- which works.
Faces-config has been edited to return back to the ViewCart.xhtml page when the button is clicked; which seems to be the case.
The PROBEM: Cart is still showing the original list, before the item was deleted.
If I go to the product catalogue and return back to ViewCart.xhtml, the executed changes are reflected in the cart. Please can someone help?
Here is the ViewCart.xhtml page
<body>
<h:outputText value="Cart List"
style="font-family: Verdana, Helvetica, sans-serif;font-size: 18px; font-weight: 900;" />
<h:form name="ViewProductsManagedBean">
<p:dataTable id="cartTable" var="cartList"
value="#{ViewProductsManagedBean.cart}" <p:column>
<f:facet name="header">
<h:outputText value="Delete Cart Item "
style="font-family: Verdana, Helvetica, sans-serif;font-size: 16px;" />
</f:facet>
<h:commandButton action="#{ViewProductsManagedBean.removeItemFromCart(cartList.itemcode)}"> </h:commandButton>
</p:column>
</f:facet>
</p:dataTable>
</h:form>
</body>
</html>
now the managed bean:
#ManagedBean(name="ViewProductsManagedBean")
#RequestScoped
public class ViewProductsManagedBean {
public String removeItemFromCart(String itemCode){
return cartFunctions.removeItemFromCart(itemCode);
}
}
The facade that "talks" to the business logic
#Stateful
#SessionScoped
public class CartFacade {
public String removeItemFromCart(String itemCode){
return cartBean.removeItemFromCart(itemCode);
}
}
The cart been looks like follows:
#Stateful
#Local(ShoppingCartLocal.class)
#Remote(ShoppingCart.class)
#SessionScoped
public class ShoppingCartBean implements ShoppingCartLocal, ShoppingCart {
public String removeItemFromCart(String itemCode){
for(Orderitem ord:cartItems){
if(itemCode.equals(ord.getItemcode())){
cartItems.remove(ord);
System.out.println("Item removed " + itemCode);
}
}
return "ViewCart";
}
here is the full cart bean
package com.shop.cart;
/**
* Created by LalinPethiyagoda on 30/07/2015.
*/
#Stateful
#Local(ShoppingCartLocal.class)
#Remote(ShoppingCart.class)
#SessionScoped
public class ShoppingCartBean implements ShoppingCartLocal, ShoppingCart {
#PersistenceContext(unitName ="Shop")
private EntityManager cartEntityManager;
private CustomerManager customerManagerBean;
private CopyOnWriteArrayList<Orderitem> cartItems = new CopyOnWriteArrayList<>();
private List<Orderitem> cartItemsReturn = new ArrayList<>();
public void setCartItems(CopyOnWriteArrayList<Orderitem> cartItems) {
this.cartItems = cartItems;
}
private CustomerEntity customer;
public ShoppingCartBean(){}
#Override
public List<Orderitem> getCartItemsReturn() {
return cartItemsReturn;
}
public void setCartItemsReturn(List<Orderitem> cartItemsReturn) {
this.cartItemsReturn = cartItemsReturn;
}
#Override
public boolean addCartItem(ProductEntity product, int quantityPurchased){
com.shop.entity.Orderitem basketItem=new Orderitem();
Locale currentLocale = new Locale("en", "GB");
double subTotal;
// check for duplicate entry.
for (Orderitem itemsIntheCart : cartItems) {
if (itemsIntheCart.getItemcode().equals(product.getItemcode())) {
return false;
}
}
basketItem.setItemcode(product.getItemcode());
basketItem.setItemdescription(product.getItemdescription());
basketItem.setUnitprice(product.getUnitprice());
basketItem.setQuantitypurchased(quantityPurchased);
subTotal = quantityPurchased * basketItem.getUnitprice();
Double currencyAmount = new Double(subTotal);
NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance(currentLocale);
currencyFormatter.format(currencyAmount);
basketItem.setSubtotal(currencyAmount);
cartItems.add(basketItem);
return true;
}
public String removeItemFromCart(String itemCode){
for(Orderitem ord:cartItems){
if(itemCode.equals(ord.getItemcode())){
cartItems.remove(ord);
System.out.println("Item removed " + itemCode);
}
}
return "ViewCart";
}
#Override
public CopyOnWriteArrayList<Orderitem> viewCartItems(){
return this.cartItems;
}
#Override
public CopyOnWriteArrayList<Orderitem> getCartItems(){
CopyOnWriteArrayList<Orderitem> cartItemList = this.cartItems;
for(Orderitem x:cartItemList){
System.out.println(x.getItemdescription());
}
return cartItemList;
}
public CustomerEntity getCustomer() {
return customer;
}
public void setCustomer(CustomerEntity customer) {
this.customer = customer;
}
public void removeCartItem(int itemCode){
System.out.println("hello");
}
#Override
public double getTotal(){
double total=0;
for(Orderitem bItem:getCartItems()){
total = total + bItem.getSubtotal();
}
return total;
}
#PreDestroy
public void exit(){
persistCartItems();
stopSession();
}
#Override
public void persistCartItems() {
// TODO Auto-generated method stub
}
#Remove
public void stopSession(){
System.out.println("saved- all done - object detached from object pool");
}
public void assignCartToCustomer(){
customer = customerManagerBean.getVerifiedCustomer();
}
public CustomerEntity getCustomerAssociatedWithTheCart(){
return this.customer;
}
#Remove
public void remove() {
cartItems = null;
}
#Override
public void incrementQuantity() {
}
#Override
public void decrementQuantity() {
}
}

org.springframework.beans.factory.BeanCreationException using cdi

I am trying to implement authentication and authorization using Spring Security Framework, but I am having a hard time, Im stuck in this exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clienteBO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected br.com.logtec.dao.GenericCrudDAO br.com.logtec.business.GenericCrudBO.dao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'crudDAO': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected javax.persistence.EntityManager br.com.logtec.dao.GenericCrudDAO.entityManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.persistence.EntityManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#javax.inject.Inject(), #br.com.logtec.factory.DataFactory()}
Those are my related classes:
#Named("clienteBO")
public class ClienteBO extends PersonificacaoBO<Cliente>{
private static final long serialVersionUID = 119528316663693560L;
public ClienteBO() {
super();
}
#Override
public Feedback salvar(Cliente instancia) {
instancia.getPessoa().setCliente(true);
//TODO PEGAR EMPRESA DO USUARIO LOGADO
// if(instancia.getEmpresa() == null)
// throw new RuntimeException("O cliente deve obrigatoriamente possuir uma empresa");
return super.salvar(instancia);
}
#Override
public Feedback salvar(Cliente instancia, CrudDAO<Cliente> dao) {
instancia.getPessoa().setCliente(true);
return super.salvar(instancia, dao);
}
#Override
protected Exemplo criarExemplo(Cliente pesquisa) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return super.criarExemplo(pesquisa);
}
#Override
public Feedback salvar(Collection<Cliente> instancias) {
for (Cliente cliente : instancias) {
cliente.getPessoa().setCliente(true);
}
return super.salvar(instancias);
}
#Override
public Feedback salvar(Collection<Cliente> instancias, CrudDAO<Cliente> dao) {
for (Cliente cliente : instancias) {
cliente.getPessoa().setCliente(true);
}
return super.salvar(instancias, dao);
}
}
public abstract class PersonificacaoBO<T extends Personificacao> extends GenericCrudBO<T>{
private static final long serialVersionUID = 5475960092794378740L;
#Override
protected Exemplo criarExemplo(T pesquisa) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Exemplo exemplo = super.criarExemplo(pesquisa);
exemplo.excludeField("pessoa.cliente");
exemplo.excludeField("pessoa.funcionario");
exemplo.excludeField("pessoa.fornecedor");
exemplo.excludeField("pessoa.usuario");
exemplo.excludeField("pessoa.contador");
return exemplo;
}
}
#Named("crudBO")
public class GenericCrudBO<E extends EntidadeBase> implements CrudBO<E>{
private static final long serialVersionUID = 1L;
private static final String DEFAULT_ERROR_MESSAGE = "Um erro inesperado ocorreu, contate o administrador do sistema.";
private static final String DEFAULT_SUCESS_MESSAGE = "Operação realizada com sucesso!";
#Inject
#Named("crudDAO")
protected GenericCrudDAO<E> dao;
public GenericCrudBO() {
super();
}
public GenericCrudBO(GenericCrudDAO<E> dao) {
super();
this.dao = dao;
}
public Feedback salvar(E instancia, CrudDAO<E> dao) {
Feedback feedback;
try {
dao.atualizar(instancia);
feedback = new Feedback(TipoFeedback.SUCESSO, EtapaFeedback.CADASTRO, DEFAULT_SUCESS_MESSAGE);
} catch (RuntimeException e) {
feedback = new Feedback(TipoFeedback.ERRO, EtapaFeedback.CADASTRO, DEFAULT_ERROR_MESSAGE);
throw e;
}
return feedback;
}
public Feedback salvar(Collection<E> instancias, CrudDAO<E> dao) {
try {
dao.cadastrar(instancias);
return new Feedback(TipoFeedback.SUCESSO, EtapaFeedback.CADASTRO, "Operação realizada com sucesso");
} catch (Exception e) {
return new Feedback(TipoFeedback.ERRO, EtapaFeedback.CADASTRO, "Erro ao salvar, contate o administrador");
}
}
#Override
public Feedback salvar(Collection<E> instancias) {
return salvar(instancias, dao);
}
public Feedback salvar(E instancia) {
return salvar(instancia, dao);
}
#Override
public Feedback deletar(E entidade) {
Feedback feedback;
try {
dao.deletar(entidade);
feedback = new Feedback(TipoFeedback.SUCESSO, EtapaFeedback.CADASTRO, DEFAULT_SUCESS_MESSAGE);
} catch (RuntimeException e) {
feedback = new Feedback(TipoFeedback.ERRO, EtapaFeedback.DELECAO, DEFAULT_ERROR_MESSAGE);
}
return feedback;
}
public E pesquisarPorId(Class<E> clazz, Long id) {
return dao.pesquisarPorId(clazz, id);
}
public E pesquisarPorId(E instancia) {
return dao.pesquisarPorId(instancia);
}
public List<E> pesquisar(Class<E> clazz) {
return dao.pesquisarTodos(clazz);
}
/**
* Pesquisa para entidades simples sem composição
*/
#Override
public List<E> pesquisar(E pesquisa) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Exemplo exemplo = criarExemplo(pesquisa);
return dao.pesquisar(exemplo);
}
protected Exemplo criarExemplo(E pesquisa) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Exemplo exemplo = new Exemplo(pesquisa);
exemplo.excludeField("serialVersionUID");
exemplo.setMatchingMode(MatchingMode.ANYWHERE);
exemplo.excludeZeroes();
return exemplo;
}
#Override
public int total(E pesquisa) {
return this.dao.total(pesquisa);
}
public List<E> listarLazy(E pesquisa, int startingAt, int maxPerPage, String sortField, String sortOrder) {
inicializarCamposPesquisa(pesquisa);
return this.dao.listarLazy(pesquisa, startingAt, maxPerPage, sortField, sortOrder);
}
protected void inicializarCamposPesquisa(E pesquisa) {
//método que deverá ser implementado pelas classes filhas que quiserem filtrar os resultados no lazyList
}
public String getListIds(List<EntidadeBase> entidades) {
StringBuilder builder = new StringBuilder('(');
EntidadeBase e = null;
for (int i = 0; i < entidades.size(); i++) {
e = entidades.get(i);
builder.append(e.getId());
if(i < entidades.size()-1) {
builder.append(',');
}
}
builder.append(')');
return builder.toString();
}
#SuppressWarnings("unchecked")
protected Class<E> getClassType() {
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
return (Class<E>) parameterizedType.getActualTypeArguments()[0];
}
}
#Named("crudDAO")
public class GenericCrudDAO<E extends EntidadeBase> implements CrudDAO<E>{
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = Logger.getLogger(CrudDAO.class);
#Inject
#DataFactory
protected EntityManager entityManager;
public GenericCrudDAO() {
super();
}
public GenericCrudDAO(EntityManager entityManager) {
super();
this.entityManager = entityManager;
}
#Override
public void cadastrar(E instancia) {
entityManager.getTransaction().begin();
entityManager.persist(instancia);
entityManager.getTransaction().commit();
}
public void cadastrar(Collection<E> instancias) {
try {
entityManager.getTransaction().begin();
for(E e : instancias) {
entityManager.merge(e);
}
entityManager.getTransaction().commit();
} catch (Exception e) {
entityManager.getTransaction().rollback();
throw e;
}
}
#Override
public void atualizar(E instancia) {
entityManager.getTransaction().begin();
entityManager.merge(instancia);
entityManager.getTransaction().commit();
}
#Override
public void deletar(E instancia) {
entityManager.getTransaction().begin();
entityManager.remove(entityManager.merge(instancia));
entityManager.getTransaction().commit();
}
public E pesquisarPorId(Class<E> clazz, Long id) {
return (E) entityManager.find(clazz, id);
}
#SuppressWarnings("unchecked")
public E pesquisarPorId(E instancia) {
Class<E> clazz = (Class<E>) instancia.getClass();
return (E) entityManager.find(clazz, instancia.getId());
}
#SuppressWarnings("unchecked")
public List<E> pesquisarTodos(Class<E> clazz) {
List<E> lista = new ArrayList<E>();
lista = entityManager.createQuery(" FROM " + clazz.getName()).getResultList();
return lista;
}
#Override
public List<E> pesquisar(Exemplo exemplo) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return QBE.using(entityManager).getList(exemplo);
}
#Override
public E pesquisarUnico(Exemplo exemplo) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
return QBE.using(entityManager).getSingle(exemplo);
}
#Override
#SuppressWarnings("unchecked")
public List<E> pesquisar(String queryString) {
return entityManager.createQuery(queryString).getResultList();
}
#SuppressWarnings("unchecked")
#Override
public List<E> pesquisar(String queryString, Map<String, Object> param) {
String key = null;
Query query = entityManager.createQuery(queryString);
for(Map.Entry<String, Object> entry : param.entrySet()) {
key = entry.getKey().trim();
key = key.startsWith(":") ? key.substring(1) : key;
query.setParameter(key, entry.getValue());
}
return query.getResultList();
}
public int total(E pesquisa) {
Long count = 0L;
try {;
Query q = entityManager.createQuery("SELECT count(*) FROM "
+ pesquisa.getClass().getName());
count = (Long) q.getSingleResult();
} catch (Exception e) {
LOGGER.error("Erro ao buscar total listagem lazy", e);
}
return count.intValue();
}
public void rollback() {
entityManager.getTransaction().rollback();
}
#SuppressWarnings("unchecked")
protected Class<E> getClassType() {
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
return (Class<E>) parameterizedType.getActualTypeArguments()[0];
}
#SuppressWarnings("unchecked")
public List<E> listarLazy(E pesquisa, int startingAt, int maxPerPage,
String sortField, String sortOrder) {
List<E> lista = new ArrayList<E>();
try {
Query q = entityManager.createQuery("FROM "
+ pesquisa.getClass().getName());
q.setFirstResult(startingAt);
q.setMaxResults(maxPerPage);
lista = q.getResultList();
} catch (Exception e) {
LOGGER.error("Erro ao buscar listagem Lazy", e);
}
return lista;
}
}
I'm a begginer on Spring Security, being so, any help is welcome, thanks
If I get this right, you want to use Spring Security for security and CDI for dependency injection.
In that case, you need to make sure that Spring and CDI don't try to manage the same beans. Even when you don't use Spring Core directly, you now have both Spring and CDI on your classpath. When Spring discovers javax.inject.Inject on its classpath, it will treat #Inject as synonymous to #Autowired and try to inject Spring beans into the annotated injection target.
That's why you get the exception - it's Spring and not CDI complaining about a missing bean.

Javafx combobox bound value cannot be set exception

I'm using trying to use a javafx combobox with a cell factory to render the list, I was using the setText on the override updateItem() of my CellList, but I found out when I change a value on the underlying model, that doesnẗ afects the deployed list on the combo box. So I try to make it binding both properties and It's works but when a try to clear the selection I have a Exception. This is the code:
import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
import javafx.util.Callback;
public class BasicComboBoxSample extends Application {
public static void main(String[] args) { launch(args); }
#Override public void start(Stage stage) {
final Employee john = new Employee("John");
final Employee jill = new Employee("Jill");
final Employee jack = new Employee("Jack");
final ComboBox<Employee> cboEmployees = new ComboBox();
cboEmployees.getItems().addAll(john, jill, jack);
cboEmployees.setValue(jill);
Button b = new Button("ChangeName");
b.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent actionEvent) {
john.setName("Maria");
}
});
Button c = new Button("Clear");
c.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent actionEvent) {
cboEmployees.getSelectionModel().clearSelection();
}
});
Button d = new Button("Select First");
d.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent actionEvent) {
cboEmployees.getSelectionModel().select(john);
}
});
Callback<ListView<Employee>, ListCell<Employee>> cellFactory = new Callback<ListView<Employee>, ListCell<Employee>>() {
#Override
public ListCell<Employee> call(ListView<Employee> listView) {
return new EmployeeListCell(); //To change body of implemented methods use File | Settings | File Templates.
}
};
cboEmployees.setButtonCell(new EmployeeListCell());
cboEmployees.setCellFactory(cellFactory);
final StackPane layout = new StackPane();
VBox v = new VBox();
v.getChildren().add(cboEmployees);
v.getChildren().add(b);
v.getChildren().add(c);
v.getChildren().add(d);
layout.getChildren().add(v);
layout.setStyle("-fx-background-color: cornsilk; -fx-padding: 15;");
stage.setScene(new Scene(layout));
stage.show();
}
class Employee {
public Employee(String name) { this.setName(name); }
private SimpleStringProperty name = new SimpleStringProperty("");
String getName() {
return name.get();
}
SimpleStringProperty nameProperty() {
return name;
}
void setName(String name) {
this.name.set(name);
}
}
public class EmployeeListCell extends ListCell<Employee> {
#Override
protected void updateItem(Employee emp, boolean b) {
super.updateItem(emp, b);
if(emp != null){
textProperty().bind(emp.nameProperty());
}
}
}
}
And the Exception was:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: A bound value cannot be set.
at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:157)
at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:67)
at javafx.beans.property.StringProperty.setValue(StringProperty.java:84)
at javafx.scene.control.Labeled.setText(Labeled.java:135)
at com.sun.javafx.scene.control.skin.ComboBoxListViewSkin.updateDisplayText(ComboBoxListViewSkin.java:420)
at com.sun.javafx.scene.control.skin.ComboBoxListViewSkin.updateDisplayNode(ComboBoxListViewSkin.java:399)
at com.sun.javafx.scene.control.skin.ComboBoxListViewSkin.getDisplayNode(ComboBoxListViewSkin.java:229)
at com.sun.javafx.scene.control.skin.ComboBoxBaseSkin.updateDisplayArea(ComboBoxBaseSkin.java:125)
at com.sun.javafx.scene.control.skin.ComboBoxBaseSkin.handleControlPropertyChanged(ComboBoxBaseSkin.java:120)
at com.sun.javafx.scene.control.skin.ComboBoxListViewSkin.handleControlPropertyChanged(ComboBoxListViewSkin.java:198)
at com.sun.javafx.scene.control.skin.SkinBase$3.changed(SkinBase.java:282)
at javafx.beans.value.WeakChangeListener.changed(WeakChangeListener.java:107)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:367)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
at javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:123)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:130)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163)
at javafx.scene.control.ComboBoxBase.setValue(ComboBoxBase.java:148)
at javafx.scene.control.ComboBox.updateValue(ComboBox.java:416)
at javafx.scene.control.ComboBox.access$300(ComboBox.java:166)
at javafx.scene.control.ComboBox$6.changed(ComboBox.java:401)
at com.sun.javafx.binding.ExpressionHelper$Generic.fireValueChangedEvent(ExpressionHelper.java:367)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:195)
at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:161)
at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:130)
at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163)
at javafx.scene.control.SelectionModel.setSelectedItem(SelectionModel.java:101)
at javafx.scene.control.ComboBox$ComboBoxSelectionModel$1.invalidated(ComboBox.java:448)
at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155)
at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100)
at javafx.beans.property.ReadOnlyIntegerWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:195)
at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:161)
at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:130)
at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:163)
at javafx.scene.control.SelectionModel.setSelectedIndex(SelectionModel.java:67)
at javafx.scene.control.SingleSelectionModel.updateSelectedIndex(SingleSelectionModel.java:208)
at javafx.scene.control.SingleSelectionModel.clearSelection(SingleSelectionModel.java:67)
at de.thomasbolz.javafx.BasicComboBoxSample$2.handle(BasicComboBoxSample.java:45)
at de.thomasbolz.javafx.BasicComboBoxSample$2.handle(BasicComboBoxSample.java:42)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Node.fireEvent(Node.java:6863)
at javafx.scene.control.Button.fire(Button.java:179)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
at javafx.event.Event.fireEvent(Event.java:171)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3328)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3168)
at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3123)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2265)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)
at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
at com.sun.glass.ui.View.notifyMouse(View.java:922)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:82)
at java.lang.Thread.run(Thread.java:722)
You need to unbind the textProperty in case the emp is null
Add the condition in EmployeeListCell class
else {
textProperty().unbind();
}

How to get parent of a custom component?

I have a custom container component, that I want to use like this:
<p:a>A
<p:a>B</p:a>
</p:a>
That should generate this markup:
<div>A
<div>B</div>
</div>
Code for the component is below.
public class TagA extends TagHandler {
Logger logger = Logger.getLogger(getClass().getName());
public TagA(TagConfig config) {
super(config);
}
public void apply(FaceletContext ctx, UIComponent parent)
throws IOException {
UIComponentBase c = new UIComponentBase() {
public void encodeBegin(FacesContext ctx) throws IOException {
//getParent() always returns UIViewRot
logger.info("Parent is: " + getParent().getClass().getName());
ResponseWriter w = ctx.getResponseWriter();
w.write("<div>");
super.encodeBegin(ctx);
}
public void encodeEnd(FacesContext ctx) throws IOException {
ResponseWriter w = ctx.getResponseWriter();
w.write("</div>");
super.encodeEnd(ctx);
}
// abstract method in base, must override
public String getFamily() {
return "com.mobiarch.nf";
}
};
parent.getChildren().add(c);
nextHandler.apply(ctx, parent);
}
}
Unfortunately, this is rendering the following markup:
<div></div>A
<div></div>B
For others in a similar situation, just develop the component and not the tag.
#FacesComponent("my.ComponentA")
public class ComponentA extends UIComponentBase {
Logger logger = Logger.getLogger(getClass().getName());
public String getFamily() {
return "my.custom.component";
}
public void encodeBegin(FacesContext ctx) throws IOException {
super.encodeBegin(ctx);
logger.info("Component parent is: " + getParent().getClass().getName());
ResponseWriter w = ctx.getResponseWriter();
w.write("<div>");
}
public void encodeEnd(FacesContext ctx) throws IOException {
super.encodeEnd(ctx);
ResponseWriter w = ctx.getResponseWriter();
w.write("</div>");
}
}
Register it in your ??.taglib.xml
<tag>
<tag-name>a</tag-name>
<component>
<component-type>my.ComponentA</component-type>
</component>
</tag>

Resources