Vaadin and Scala

Hi, Thanks for Scaladin. Do you have plans to develop it further? One idea I use is this:

[code]
trait Reset { self: Property[_]
=>
def reset = value = None
}

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.

Hi, is it possible to use scaladin with spring?

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{

@Autowired
private aRepository MyRepository;


@Override
public void enter(ViewChangeEvent event) {
    //view content
}

}
[/code]But when I try to access a scala view like so:

[code]
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
import ru.xpoft.vaadin.VaadinView
import vaadin.scala.BeanItemContainer
import vaadin.scala.Table
import vaadin.scala.VerticalLayout
import com.fdariasm.siac.repositories._
import scala.collection.JavaConverters._
import vaadin.scala.Navigator.View
import vaadin.scala.Navigator.ViewChangeEvent

@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?.

Hello Everybody,

I am a beginner scala, vaadin ( scaladin ) user and would love to be able to deploy a scaladin app to heroku

Is there anyone who could please help ? for example create a g8 template or any other way they see fit ?

I really Hope someone will respond.

Thank you

I am writing an app using scaladin and was wondering about the future of scaladin too.

Is there a way to make case classes work with forms without writing much code?

Yes, it’s possible:

case classs Test(
  @BeanProperty var id: Int,
  @BeanProperty var name: String
)

Thanks, Lukasz!

What is the best way in Scala world to validate models? I decided to try out java class BeanValidator:

validators += { (elem: Option[Any]
) ⇒
        Validator(new BeanValidator(classOf[Shop]
, "name")).validate(elem)
      }

but it fails with exception:

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)

In build.sbt I have these:

"javax.validation" % "validation-api" % "1.1.0.Final",
"org.hibernate" % "hibernate-validator-annotation-processor" % "5.1.1.Final"

Maybe, You should use

hibernate-validator

dependency

Yep, added these and it worked!

I will try to use bean validators then :slight_smile:

"org.hibernate" % "hibernate-validator" % "5.1.1.Final",

  "javax.el" % "javax.el-api" % "2.2.5",

  "org.glassfish.web" % "javax.el" % "2.2.6",

Although there was a little trick to make the annotations work:

import scala.beans.BeanProperty
import javax.validation.constraints.NotNull
import javax.validation.constraints.Size
import scala.annotation.target.field

case class Shop(
  @BeanProperty var id: Option[Long]
 = None,
  @(NotNull @field)@(Size @field)(min = 1, max = 255)@BeanProperty var name: String,
  @BeanProperty var address: String) {
}

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?

Is there likely to be an update to Scaladin for Vaadin 7.5.x?

Thanks.

Hi there,

Is there a Scaladin way to use SQLContainer and TableQuery/FreeformQuery?

Thank you!

Has Scaladin been abandoned? If it hasn’t, does the current version work with Vaadin 7.6.x?

Thanks…

Last update was in Jan.

If you want to checkout the latest code you can use jitpack (as last official release was 3.1)

https://jitpack.io/#henrikerola/scaladin/-SNAPSHOT

Is there a way to add buttons to a table with scaladin?

So far I only get String name of the class eg Vaadin.scala.Button@488bceb

The property is defined like this:

userTable.addContainerProperty(“Password”, classOf[Button]
, None)

and the value set like this:

rowItem.getProperty(“Password”).value_=(btn)

scaladin 3.1.0, vaadin 7.6.4

Found a way that worked.

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)

Question for Property trait in Scaladin:

I have a Custom component like this:

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.

¿Any idea or comment?

Hi there! I have a simple question: does Scaladin work with the latest, 7.7.1 version of Vaadin?

Thanks.

I´m using Vaadin 8.1.0 and I want to know how can use functional interfaces in scala. Something like this:

column.setEditorComponent(component, Account::setStatus)

Mor eprecisely, har do I map the lambda BeanObject::setterMethod in scala. ANy idea?