Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As you can see from the <a href="https://github.com/henrikerola/scaladin/blob/2.2/addon/src/main/scala/vaadin/scala/CustomComponent.scala" rel="nofollow">CustomComponent</a> source </p> <pre><code>class CustomComponent(override val p: com.vaadin.ui.CustomComponent with CustomComponentMixin = new com.vaadin.ui.CustomComponent with CustomComponentMixin ) extends AbstractComponent(p) { ... inner code } </code></pre> <p>You pass the corresponding vaadin component as a contructor argument <code>p</code> (which usually stands for "peer")</p> <p>That is, the scaladin component is a wrapper around your original component.</p> <p>To override the behavior of the peer component, you have to do it when you pass it to the wrapper constructor.</p> <p>You have different choices here</p> <hr> <p><strong>With anonymous subclass</strong></p> <pre><code>class CostPlanImport(override val p: com.vaadin.ui.CustomComponent with CustomComponentMixin = new com.vaadin.ui.CustomComponent { def attach() { //your code here } with CustomComponentMixin ) extends CustomComponent(p) </code></pre> <hr> <p><strong>With a trait</strong></p> <pre><code>trait AttachBehavior { self: com.vaadin.ui.Component =&gt; def attach() { //your reusable code here } } class CostPlanImport(override val p: com.vaadin.ui.CustomComponent with CustomComponentMixin = new com.vaadin.ui.CustomComponent with CustomComponentMixin with AttachBehavior ) extends CustomComponent(p) </code></pre> <hr> <p><strong>With a <code>CustomComponent</code> subclass</strong></p> <p>[not shown, but is a mix of the preceding two examples]</p> <hr> <p><em>Note: the code examples are not tested</em></p> <hr> <p><strong>UPDATE</strong></p> <p>If you need to pass parameters from your "wrapper component" constructor to the peer's method, you can</p> <pre><code>class CostPlanImport( name: String, cost: Double, ) extends CustomComponent( p = new com.vaadin.ui.CustomComponent { def attach() { //your code here //with "name" &amp; "cost" visible } with CustomComponentMixin ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload