Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchError on BeanContainer #24

Open
phancox opened this issue Jun 15, 2013 · 0 comments
Open

MatchError on BeanContainer #24

phancox opened this issue Jun 15, 2013 · 0 comments
Assignees
Labels

Comments

@phancox
Copy link

phancox commented Jun 15, 2013

Lacking much understanding of Scaladin internals, I'm unsure if this is a bug or not. It relates to a MatchError when trying to retrieve an item from a BeanContainer and how these items are wrapped. Using Scaladin 3

private val cbxAssociation = new ComboBox {
  caption = "Please Select Your Association"
  nullSelectionAllowed = false
  description = "Select the association where you are registering these members."
  inputPrompt = "Association Name"
  width = 150 px;
  itemCaptionPropertyId = "name"
  immediate = true
  p.setContainerDataSource(new BeanContainer[Int, Association](classOf[Association]) {
    import com.googlecode.mapperdao.Query.{ select => dbselect }
    val a = SportZmanInternetUI.associationEntity
    val query = dbselect from a orderBy a.name
    val associations = SportZmanInternetUI.queryDao.query(query)
    associations foreach { association =>
      addItem(association.id, association)
    }
  })
  valueChangeListeners += { evt =>
    val selectedAssociationId = evt.property.value.get.asInstanceOf[Int]
    val association = getItem(selectedAssociationId)
    debug("****" + association)
  }

This code throws the following exception

Caused by: scala.MatchError: com.dtc.sportzman.internet.PayMembershipFeesPanel$$anon$2$$anon$6@5d63a2b3 (of class com.dtc.sportzman.internet.PayMembershipFeesPanel$$anon$2$$anon$6)
   at vaadin.scala.internal.WrapperUtil$.wrapperFor(WrapperUtil.scala:12)
   at vaadin.scala.Wrapper$class.wrapperFor(Wrapper.scala:8)
   at vaadin.scala.AbstractComponent.wrapperFor(AbstractComponent.scala:25)
   at vaadin.scala.Container$Viewer$class.container(Container.scala:151)
   at vaadin.scala.AbstractSelect.container(AbstractSelect.scala:31)
   at vaadin.scala.AbstractSelect.wrapItem(AbstractSelect.scala:86)
   at vaadin.scala.Container$class.optionalWrapItem(Container.scala:61)
   at vaadin.scala.AbstractSelect.optionalWrapItem(AbstractSelect.scala:31)
   at vaadin.scala.Container$class.getItem(Container.scala:26)
   at vaadin.scala.AbstractSelect.getItem(AbstractSelect.scala:31)
   at com.dtc.sportzman.internet.PayMembershipFeesPanel$$anon$2$$anonfun$3.apply(PayMembershipFeesPanel.scala:48)
   at com.dtc.sportzman.internet.PayMembershipFeesPanel$$anon$2$$anonfun$3.apply(PayMembershipFeesPanel.scala:46)
   at vaadin.scala.internal.ValueChangeListener.valueChange(listeners.scala:72)

Obviously the Scaladin code isn't prepared for this but I don't know where to fix?

def wrapperFor[T](maybeWrapper: Any): Option[T] = {
  if (maybeWrapper == null)
    None
  else
    maybeWrapper match {
      case mixin: ScaladinMixin => Option(mixin.wrapper.asInstanceOf[T])
      case interfaceMixin: ScaladinInterfaceMixin => Option(interfaceMixin.wrapper.asInstanceOf[T])
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants