first, thank you for your great work of making Vaadin usable in Scala!
While looking through the source I noticed that there are only a very few implicit conversions, which was suprising for a “wrapper library”. I am much interested in the rationale behind the decision not to use the
pimp my library pattern (As also suggested by Helder Batista above). Using this pattern large parts of the wrappers could be implemented transparent to the user, so transitioning to the the library from ordinary Scala code could be done with ease. In addition to that, maintenance could be easier (just a guess) since there is no need to reproduce the inheritance tree in the wrapped classes.
I see the problem, that implicit resolution is hard to understand, especially for novices. Reducing the use of implicits to this idiomatic pattern might be feasible for beginners.
I put together a
small example how the implementation and usage could look like - building on the “pimp my library” pattern.
The problem with the “pimp my library” pattern you demonstrate is that there are both original Java style methods and added Scala style methods directly available for the developer. With the approach we took in Scaladin, we wanted to provide pure and clean Scala API. With our approach the user would only need import stuff from org.vaadin.scala._ so it’s very clear to use.
trait TextReset extends Reset { self: Property[String]
=>
override def reset = value = “”
}
…
val firstNameField = add(new TextField with TextReset { caption = “First Name” })
val lastNameField = add(new TextField with TextReset { caption = “Last Name” })
val birthdayField = add(new PopupDateField with Reset { caption = “Birthday” })
…
def clear {
root filterRecursive(.isInstanceOf[Reset]
) map (.asInstanceOf[Reset]
) foreach (_.reset)
}
[/code]The idea is to have a trait to mark resetable fields with and then it is very convenient to clear the form.
I’m trying to create a view in scala using scaladin and integrate it with spring via springvaadinintegration addon, but I’m getting an IllegalArgumentException when I try to access the view.
In my project I have a Java UI:
@Scope("prototype")
@Component(value="ui")
@PreserveOnRefresh
public class MyUI extends UI{
private DiscoveryNavigator navigator;
@Override
protected void init(VaadinRequest request) {
navigator = new DiscoveryNavigator(this, this);
}
}
Then I have some Java views (which work well) like this one:
[code] @Component @Scope(“prototype”) @VaadinView(“main”)
public class AView extends VerticalLayout implements View{
@Component @Scope(“prototype”) @VaadinView(“scalaciudades”)
class CiudadesView () extends VerticalLayout with View{
val ciudades = List()
val table = new Table{
caption = “Ciudades”
sizeFull;
container = new BeanItemContainer(ciudades)
visibleColumns = Seq(“codCiudad”, “nombre”)
}
components += ( table )
override def enter(event: ViewChangeEvent): Unit = {}
}
[/code]I’m getting the error, the stacktrace is:
java.lang.IllegalArgumentException: Trying to navigate to an unknown state 'scalaciudades' and an error view provider not present
at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:528)
at ru.xpoft.vaadin.DiscoveryNavigator.navigateTo(DiscoveryNavigator.java:198)
at com.vaadin.ui.UI.doInit(UI.java:630)
at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:223)
at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:73)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:37)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1390)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Am I doing something wrong or is not possible this way?.
SEVERE:
javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110)
at com.vaadin.data.validator.BeanValidator.getJavaxBeanValidatorFactory(BeanValidator.java:167)
at com.vaadin.data.validator.BeanValidator.getJavaxBeanValidator(BeanValidator.java:182)
at com.vaadin.data.validator.BeanValidator.validate(BeanValidator.java:115)
at vaadin.scala.Validator$$anon$2$$anonfun$1.apply$mcV$sp(Validation.scala:63)
at vaadin.scala.Validator$$anon$2$$anonfun$1.apply(Validation.scala:63)
at vaadin.scala.Validator$$anon$2$$anonfun$1.apply(Validation.scala:63)
at scala.util.control.Exception$Catch$$anonfun$withTry$1.apply(Exception.scala:129)
at scala.util.control.Exception$Catch$$anonfun$withTry$1.apply(Exception.scala:129)
at scala.util.control.Exception$Catch.apply(Exception.scala:102)
at scala.util.control.Exception$Catch.withTry(Exception.scala:129)
at vaadin.scala.Validator$$anon$2.validate(Validation.scala:63)
Hi, I was just trying to use org.tepi.filtertable.FilterTable.
I have compiled it and tried to just simple replace regular Table with FilterTable in some example.
But I am getting:
[error]
\VaadinScalaUI.scala:24: inferred type arguments [org.tepi.filtertable.FilterTable]
do not conform to method add's type parameter bounds [C <: vaadin.scala.Componenton
on:
[code]
val table = new FilterTable {
addContainerProperty(“Test”, classOf[String]
, None)
}
content = new VerticalLayout {
add(table, ratio = 1)
}
[/code]Would somebody give me a hint what should I do?
set the container Property like this:
userTable.addContainerProperty(“Password”, classOf[ com.vaadin.ui.Button ]
, None)
and add the button like this:
val btn = new Button // this is a scala.vaadin.Button - but the .p refers to the wrapped com.vaadin.ui.Button
rowItem.getProperty(“Password”).value_=(btn.p)
class MyComponent extends CustomComponent with Property[String]
{
// code to implement the Property trait
}
With Scaladin the problem is that Property Trait has the same p method as CustomComponent to do the encapsulation. So the error is ovverrdie the method in p property for Property trait… is ambiguos and has diferent parameter.