FIELD object not having setConverter() method

Hello,
I’m initializing a FIELD variable using FormFieldGroup buildAndBind method which returns a TextField type. Here setConverter method is available for TextField but I’m not getting that method in newly initialized FIELD variable.
FYI, I’m using Vaadin 7.2.6. The code snippets is given below-

Field rciCostField = formFieldGroup.buildAndBind(“Cost”, “changeCost”, TextField.class);
rciCostField.( setConverter method not available)

Is there any way around to have setConverter method in FIELD object ?

The setConverter method is not defined in the Field interface, but instead on the AbstractField implementation. So no, there is no way of accessing the setConverter method from the the Field interface, however you could do it if you declare your variable as an AbstractField

Is there a reason why are you using the Field interface directly?

As reference:
https://vaadin.com/api/7.3.2/com/vaadin/ui/AbstractField.html

Regards

Because buildAndBind is genericized on the field type, you can also simply do:

TextField rciConstField = formFieldGroup.buildAndBind("Cost", "changeCost", TextField.class);

I tried with AbstractField and TextField both. It allows me to use setConverter method but commit method.
I’m getting an exception message while tring to execute below the code snippets.

try {
formFieldGroup.commit();
} catch (CommitException e) {
// Exception message
}

Which exception are you getting? Could you please post the stacktace?

INFO: User: Mr ProjectManager
SEVERE: com.vaadin.data.fieldgroup.FieldGroup$CommitException: Commit failed
at com.vaadin.data.fieldgroup.FieldGroup.commit(FieldGroup.java:465)
at com.groupbuilder.gb.RCIEditor.buttonClick(RCIEditor.java:824)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:984)
at com.vaadin.ui.Button.fireClick(Button.java:393)
at com.vaadin.ui.Button$1.click(Button.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:295)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:188)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:93)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1401)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
17006.jpg

The CommitException itself doesn’t tell much – the exception that caused it (getCause()) is more relevant.

I apologize for my mistake that I did in my internal code portion which triggering that exception. It is ok now. Thank you all for your kindful help.