LookupPickerField in FieldGroup

If we use optionsDatasource we get lookupField in the fieldGroup that I have been using frequently. However, How can we get the LookupPickerField instead inside a fieldGroup?


<vbox id="fieldGroupBox">
    <fieldGroup id="fieldGroup"
                datasource="resourceDs">
        <column width="250px">
            <field id="resourceCode"/>
            <field id="name"/>
            <field id="factory"
                   optionsDatasource="factoryDs"/>
            <field id="resourceGroup"
                   optionsDatasource="resourceGroupDs"/>
            <field id="factoryProductionStage"
                   optionsDatasource="factoryProductionStageDs"/>
      ......
        </column>
    </fieldGroup>
</vbox>
1 Like

I Think you can create this in the java code like this:

@Named("fieldGroup.country")
private PickerField countryField;

@java.lang.Override
public void init(java.util.Map<java.lang.String, java.lang.Object> params) {
    countryField.addClearAction();
    countryField.addLookupAction();
    countryField.addOpenAction();
}

There i have created one entity Country. And an entity for Customer, customer has an ASSOCIATION to Country.
The default is a LookupField. Now in the code you can add features like Lookup, Open and Clear.

Is it what you want?

Yes, this is what I was looking for. Thank you so much.

Hi,
is this possible with a table somehow as well?

Gabor

If you mean an editable table, then yes - use the addGeneratedColumn() method. See an example of using this method here.

1 Like

Hi Konstantin,

yeah, that’s exactly what I needed! It works perfectly. :slight_smile:

Cheers
Gabor

Hello

I use the same code as the example, but when I run the programm I get the following error:


com.haulmont.cuba.core.sys.javacl.compiler.CharSequenceCompilerException: Compilation failed. Causes: 
OrderEdit.java:11: error: cannot find symbol
    private PickerField clientField;
            ^
  symbol:   class PickerField
  location: class com.company.workshop.web.order.OrderEdit OrderEdit.java:10: error: cannot find symbol
    @Named("fieldGroup.client")
     ^
  symbol:   class Named
  location: class com.company.workshop.web.order.OrderEdit 
	at com.haulmont.cuba.core.sys.javacl.compiler.CharSequenceCompiler.compile(CharSequenceCompiler.java:178)
	at com.haulmont.cuba.core.sys.javacl.JavaClassLoader.loadClass(JavaClassLoader.java:167)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
	at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:677)

I miss to import a class or library ?

These are my imports:


package com.company.workshop.web.order;

import javax.inject.Inject;
import com.company.workshop.entity.OrderStatus;
import com.company.workshop.service.OrderService;
import com.haulmont.cuba.gui.components.AbstractEditor;
import com.company.workshop.entity.Order;

public class OrderEdit extends AbstractEditor<Order> {
    @Named("fieldGroup.client")
    private PickerField clientField;

Try recreate the ItelliJ files from Cuba Studio.

at this time I am not using intelliJ, I use only cuba studio editor.
After that, I closed the studio etc and restart again, then I tried to start the application server and I got again the following errors:


[22:27:35.290] Ready
[22:28:11.865] Restarting the application server
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead. 
at build_6jo8oxswb1bewvutm0guna9l3$_run_closure4.doCall(C:\Users\George\studio-projects\workshop\build.gradle:88) 
:app-core:assembleDbScripts UP-TO-DATE 
:app-core:dbScriptsArchive UP-TO-DATE 
:app-global:compileJavaNote: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.  
:app-global:enhance 
:app-global:processResources UP-TO-DATE 
:app-global:classes 
:app-global:jar 
:app-core:compileJava 
:app-core:processResources UP-TO-DATE 
:app-core:classes 
:app-core:jar UP-TO-DATE 
:app-core:sourceJar UP-TO-DATE 
:app-core:assemble UP-TO-DATE 
:app-core:cleanConf 
:app-core:deploy 
:app-gui:compileJava UP-TO-DATE 
:app-gui:processResources UP-TO-DATE 
:app-gui:classes UP-TO-DATE 
:app-gui:jar UP-TO-DATE 
:app-web:compileJavaC:\Users\George\studio-projects\workshop\modules\web\src\com\company\workshop\web\order\OrderEdit.java:11: error: cannot find symbol
     private PickerField clientField;
	 ^   symbol:   class PickerField
	 location: class OrderEdit 
C:\Users\George\studio-projects\workshop\modules\web\src\com\company\workshop\web\order\OrderEdit.java:10: error: cannot find symbol
     @Named("fieldGroup.client")
	 ^   symbol:   class Named
	 location: class OrderEdit 
2 errors
  FAILED

  FAILURE: Build failed with an exception.  
 
 * What went wrong: Execution failed for task '
:app-web:compileJava'. 
> Compilation failed; see the compiler error output for details.  

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.  BUILD FAILED  Total time: 25.979 secs [22:28:39.052] Task 'deploy, start' failed
org.gradle.api.internal.tasks.compile.CompilationFailedException: 

Compilation failed; see the compiler error output for details.

I would recommend using IntelliJ community. It will help you solve any import errors.
If you want me to help you further, you have to upload the project without the build folder.

Thank you Kjell,

I am new in cuba, and tried the example
https://www.cuba-platform.com/tutorials/displaying-relationships-between-entities-part-1
I will search a litle and maybe I will make a new question.

Finally and after following your suggestions, I was able to setup IntelliJ and it suggested me the missing import!


import com.haulmont.cuba.gui.components.PickerField;

I searched a lot and I did not find the import statment for the PickerField, also not at the specific pages for this contol.

https://doc.cuba-platform.com/manual-6.3/gui_PickerField.html

https://demo.cuba-platform.com/sampler/#!

Thanks a lot Kjell

1 Like

This page may help you to see how the controllers can be used.
[Sampler page] (https://demo.cuba-platform.com/sampler/#!)

Look at the spure tab for xml or java.

Hi,

Studio is not aimed at normal Java development. Please always use Eclipse or Intellij for your business logic development. You can easily go to the IDE using Ctrl + I shortcut in the Screen Designer or using IDE buttons in the navigation panel.

1 Like