override client side

Hi vaadiners!
I want override client side of calendar in vaadin 7.1.0.
How can i make this?

P.S.
I tried to move classes from vaadin 7.1.0 to my project ( and created htere WidgetSet ). But when compile whe WidgetSet of my Main project, in run time of my app i get “Widgetset does not contain implementation…”.

Thanks.

Help, I need somebody
Help, not just anybody
Help, you know, I need someone
Help …

Have a look at
this thread
. Specifically at Johannes’ first post.
What you have to do: Create a new class which extends the client-side class you want to override.
In that class override what you want.
Add a replace-with tag to your widgetset.gwt.xml which replaces the original class with your one.

Thanks Marius, it is helpful information.

I’m stuck.
I did as said Marius, but nothing has changed.

MyCalendar


public class MyVCalendar extends VCalendar {
     @Override
     public void setDayNames(String[] names) {
         String[] newNames = new String[names.length]
;
         for(int i = 0 ; i< names.length; i++){
             newNames = names+"My";
         }
        super.setDayNames(newNames);
    }
}


My WidgetSet.gwt.xml


    <replace-with class="my.test.web.ui.calendar.MyVCalendar">
        <when-type-is class="com.vaadin.client.ui.calendar.VCalendar" />
    </replace-with>

Then compile WidgetSet and nothing changes.
Someone can tell me why this does not work?

Have you specified your own widgetset in your applications web.xml file?

Hi John.
Yes i specified in web.xml my WidgetSet:


<init-param>
			<param-name>widgetset</param-name>
			<param-value>my.test.WidgetSet</param-value>
</init-param>

I also noted that your
my.test.web.ui.calendar.MyVCalendar
-class is not under the client package. The gwt compiler will not find the class unless it is under the client package (or you specifically tell it to search elsewhere).

Try moving MyVCalendar to
my.test.web.
client
.ui.calendar.MyVCalendar
and try recompiling the widgetset again.

Beginning more and more interesting.

now i get WidgetsetCompilation error:



.......

  HorizontalSplitPanelConnector will be in the deferred bundle
               Will serialize class com.vaadin.shared.ui.splitpanel.HorizontalSplitPanelState as a bean
   [ERROR]
 An internal compiler exception occurred
com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
	at com.google.gwt.dev.jjs.ast.JVisitor.translateException(JVisitor.java:109)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:276)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
	at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:116)
	at com.google.gwt.dev.jjs.ast.JReturnStatement.traverse(JReturnStatement.java:39)
	at com.google.gwt.dev.jjs.ast.JModVisitor$ListContextImmutable.traverse(JModVisitor.java:170)
	at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemoveImmutable(JModVisitor.java:336)
	at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:83)
	at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
	at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:137)
	at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:133)
	at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:82)
	at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
	at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:434)
	at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:403)
	at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
	at com.google.gwt.dev.jjs.impl.UnifyAst.mainLoop(UnifyAst.java:900)
	at com.google.gwt.dev.jjs.impl.UnifyAst.exec(UnifyAst.java:625)
	at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:683)
	at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
	at com.google.gwt.dev.Precompile.precompile(Precompile.java:278)
	at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
	at com.google.gwt.dev.Precompile.precompile(Precompile.java:141)
	at com.google.gwt.dev.Compiler.run(Compiler.java:232)
	at com.google.gwt.dev.Compiler.run(Compiler.java:198)
	at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
	at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
	at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
	at com.google.gwt.dev.Compiler.main(Compiler.java:177)
	at com.vaadin.tools.WidgetsetCompiler$1.run(WidgetsetCompiler.java:80)
	at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: my.test.web.client.ui.calendar.MyVCalendar
	at com.google.gwt.dev.jjs.impl.UnifyAst.searchForTypeBySource(UnifyAst.java:981)
	at com.google.gwt.dev.jjs.impl.UnifyAst.access$1500(UnifyAst.java:120)
	at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleGwtCreate(UnifyAst.java:364)
	at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleMagicMethodCall(UnifyAst.java:433)
	at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.endVisit(UnifyAst.java:237)
	at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:243)
	at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
	... 34 more
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3989): GWT.create(VCalendar.class)
         com.google.gwt.dev.jjs.ast.JMethodCall
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3989): return GWT.create(VCalendar.class)
         com.google.gwt.dev.jjs.ast.JReturnStatement
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3988): {
  return GWT.create(VCalendar.class);
}
         com.google.gwt.dev.jjs.ast.JBlock
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3988): {
  return GWT.create(VCalendar.class);
}
         com.google.gwt.dev.jjs.ast.JMethodBody
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3988): public Object invoke(Object target, Object[] params);

         com.google.gwt.dev.jjs.ast.JMethod
Widgetset compilation failed

It is strange how i compile my widget set before.
Now it is not compiling.
Where must i place MyVcalendar fore gwt compiler sow it?

MyCalendar is under package:
my.test.web.client.ui.calendar.MyVCalendar


	<replace-with class="my.test.web.client.ui.calendar.MyVCalendar">
		<when-type-is class="com.vaadin.client.ui.VCalendar" />
	</replace-with>

Do you have your WidgetSet.gwt.xml file in the same package as your client package (e.g. in
my.test.web
) ?

No.
It is under my.test.WidgetSet.gwt.xml
it must be in the same?
I tried compile it under puckeg:

my.test.web.calendar.gwt.WidgetSet.gwt.xml
and
my.test.web.calendar.client.ui.MyVCalendar

and the same compile error:


Caused by: java.lang.NoClassDefFoundError: my.test.web.calendar.client.ui.MyVCalendar
	at com.google.gwt.dev.jjs.impl.UnifyAst.searchForTypeBySource(UnifyAst.java:981)
	at com.google.gwt.dev.jjs.impl.UnifyAst.access$1500(UnifyAst.java:120)
	at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleGwtCreate(UnifyAst.java:364)
	at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleMagicMethodCall(UnifyAst.java:433)
	at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.endVisit(UnifyAst.java:237)
	at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:243)
	at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
	at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
	... 34 more
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3396): GWT.create(VCalendar.class)
         com.google.gwt.dev.jjs.ast.JMethodCall
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3396): return GWT.create(VCalendar.class)
         com.google.gwt.dev.jjs.ast.JReturnStatement
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3395): {
  return GWT.create(VCalendar.class);
}
         com.google.gwt.dev.jjs.ast.JBlock
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3395): {
  return GWT.create(VCalendar.class);
}
         com.google.gwt.dev.jjs.ast.JMethodBody
      [ERROR]
 at ConnectorBundleLoaderImpl.java(3395): public Object invoke(Object target, Object[] params);

         com.google.gwt.dev.jjs.ast.JMethod
Widgetset compilation failed

If your widgetset is at my.test.WidgetSet.gwt.xml, your client side code (including the widget, the connector etc.) must be in my.test.client.* (or some subpackage of it) unless you specify otherwise in your .gwt.xml file.

Thanks Henri!
It did not work because of this.