Vaadin Combobox does not shows nameField from database - vaadin

I have a service class. When I set items alldata() in my combo box then it shows all the embedded data from the database. how can I just set the name field?
example:
private ComboBox groundComboBox = new ComboBox<>("Ground");
groundComboBox.setItems(groundService.getAllGround());
it shows:
Ground(groundId=Shere-Bangla, groundName=Shere-Bangla national stadium, city=Dhaka, country=Bangladesh, longitude=90.8, latitude=45.7, capacity=10000, inaugurationDate=2005-02-05).
i just want to show the only name;

You need to set the label generator to define what will be the label of each item.
groundComboBox.setItemLabelGenerator(Ground::getName);
or
groundComboBox.setItemLabelGenerator(ground -> ground.getName());

Related

Make cascading list mandatory on JIRA based on another cascading list

I think this can be achieved with behaviors but I am struggling with the code.
I am trying to make "Cascading list 2" mandatory when an option is picked from "Cascading list 1"
Eg:
On "Cascading list 1" if a user picks option "A" then they have to also fill out "Cascading list 2"
If they pick option "B" on "Cascading list 1" then "Cascading list 2" is not required.
This is some of the code I was playing around with:
def fieldA = getFieldByName('BI Reporting & Analytics Request Categories') //this is cascading list 1
def fieldC = getFieldByName('Reporting') //this is the cascading list 2
def fieldAValuesThatTriggerFieldCRequired = ['Reporting'] //this is the option choosen in cascading list 1
def valueA = fieldA.value
def fieldCIsRequired = valueA in fieldAValuesThatTriggerFieldCRequired
fieldC.setRequired(fieldCIsRequired)
Any assistance is appreciated.
Image on JIRA
Thanks.
If my understanding is correct, they are not cascading field.
The request here is that when field A has particular value saying 'aaa', then field B becomes required (mandatory).
This is a typical use case for Jira plugin Adaptavist ScriptRunner behaviours.
But Behaviours is only available for Jira server or data center version. It is not for Jira cloud.
If your Jira is server version, you can refer to below steps and scripts:
go to behaviours settings, if you don't have a behaviour item for
your workflow, please create it. If behaviour has been created,
click into action/edit.
choose the field A and add it.
click Add server-side script, you will see the black inline edit section.
add below code.
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import groovy.transform.BaseScript
#BaseScript FieldBehaviours fieldBehaviours
FormField field1 = getFieldById(getFieldChanged()) // we need to capture the change in field 1.
FormField pmAuthor = getFieldByName("field2")
if (field1.getValue()) { // to check if field1 has value as the action on field could be a deleting value operation.
if (field2.getValue()=="A") {
field2.setRequired(true)
} else {
field2.setRequired(false)
}
} else { // if the value was deleted, then remove the requirement.
field2.setRequired(false)
}

Radstudio ListView and FireDac Binding Synch Issue

I have a table with a primary key (ID) and a unique field (REF) that I want to bind to a ListView.
With LiveBindings the links are created with :
1) (Table) * <-> Synch (ListView)
2) (Table) ref -> Item.Text (ListView)
Additionaly, a link are created with other component:
3) (Table) ref -> Text (ListBoxItem1)
ALL WORKS FINE if IndexFieldNames of Table are ID.
But I want to sort records by REF and when I set IndexFieldNames = ref the selected table record is always the PREVIOUS selected item on ListView, this means:
At same time that the selected ListView.Item.Text = "Ref of Record no. 2" the ListBoxItem1.Text = "Ref of Record no. 1".
I'm new with live bindings, did I make some mistake?
Before set IndexFieldNames, You need call the procedure ResetNeeded of TBindSourceDB component
I only get a workaround:
1) Do NOT connect synch of listview;
2) IndexFieldNames = ref
3) Inside event OnClick (ListView) use a Table.Locate to set the correct clicked record.

Can two item renderers be used for a grid column in Adobe flex?

I have a data grid with multiple columns among which one is for stock date. Based on the data i am getting from the backend,when a flag is disabled,i want the date to be displayed as a label,otherwise i want the start date to be editable date field. How can this be done? I have tried this below code but its takes the last rendered item as item renderer. Cause as i loop in,the condition for different records change and rendering it this way doesnt seem to work. Please help.
private function resultHandler_tbd(event:ResultEvent):void{
var myAC: ArrayCollection= event.result as ArrayCollection; //data from backend
myDataGridId.dataprovider= myAC;
for(var i:int=0;i<myAC.length;i++){
mylist=myAc[i];
if(mylist.tbdType=="Plan" && flag==true){
plnStartDate.itemrenderer= new ClassFactory(CustomCalenderRenderer);
}else
plnStartDate.itemrenderer = new ClassFactory(CustomLabelRenderer);
}
}
}
Have the "flag" property set in data for item renderer
Create a custom itemrenderer which will have both component, CustomCalenderRenderer and CustomLabelRenderer and binded with data.flag for includedInLayout or not
Thanks

Transfer a data set from openoffice base to calc

After I did a query in openoffice-base over a customized form I want to transfer a selected set of data into a template openoffice-calc table. I know I can access the data set in openoffice-calc via pressing the Data Source (F4) button but then I only get access over the query. The best solution would be after the database query over a form a button event is required to open a openoffice-calc table from the template and insert the data from the data set.
First go to Tools -> Macros -> Organize Macros -> LibreOffice Basic and add this code. Change the path of the template file.
Sub Copy_Record_To_Calc(oEvent)
Dim oForm
Dim templatePath As String
Dim oServiceManager As Object, oDesktop As Object
Dim oFileProperties As Object
Dim oDoc As Object, oSheet As Object, oCell As Object
Dim column As Integer
oForm = oEvent.Source.getModel().getParent()
If oForm.isAfterLast() Then
Print "Hey, you are after the last element."
Exit Sub
ElseIf oForm.isBeforeFirst() Then
Print "Hey, you are before the first element."
Exit Sub
End If
templatePath = "file:///C:/Users/JimStandard/Desktop/Untitled 2.ots"
Set oServiceManager = CreateObject("com.sun.star.ServiceManager")
Set oDesktop = oServiceManager.createInstance("com.sun.star.frame.Desktop")
Set oFileProperties(0) = new com.sun.star.beans.PropertyValue
oFileProperties(0).Name = "AsTemplate"
oFileProperties(0).Value = True
Set oDoc = oDesktop.loadComponentFromURL( _
templatePath, "_blank", 0, Array(oFileProperties))
oSheet = oDoc.Sheets(0)
For column = 1 to 2
oCell = oSheet.getCellByPosition(column - 1, 0)
oCell.String = oForm.getString(column)
Next column
End Sub
Then in form design mode, right-click on the button and choose Control. In the Events tab, click the three dots next to Execute action. Click Macro... and find the Copy_Record_To_Calc macro that you added.
Now turn design mode off. Go to a record and click the button. It will open the Calc template and copy the first two columns of the current record into column A and B of the spreadsheet.
See also:
Section 4.2.1 of Andrew Pitonyak's Base Macros (PDF)
ResultSet documentation
This thread gives an example of using a Calc template.

SpreadsheetGear range explorer Usage in Windows application

I am able to show the range explorer and also the numberformat category of it in my windows app using its default constructor, but really dont know how to retrieve the selected number format and pass it to the form's textbox. I am very new to spreadsheetGear. Can anyone help in using the range explorer. Thanks in Advance
Short answer: After the range explorer is closed, set the the Text property of the text box to the NumberFormat property of one of the cells within the range used in the range used in the RangeExplorer constructor.
textbox1.Text = worksheet.Cells["A1"].NumberFormat;
Longer answer: You can set up the range explorer like the code below.
// Select a range of cells.
workbookView.ActiveWorksheet.Cells["A1:C3"].Select();
// Get the active workbook set.
SpreadsheetGear.IWorkbookSet workbookSet = workbookView.ActiveWorkbookSet;
// Create the Range Explorer which operates on the current range selection.
SpreadsheetGear.Windows.Forms.RangeExplorer explorer
= new SpreadsheetGear.Windows.Forms.RangeExplorer(workbookSet);
// Set up some FormClosed event handler.
explorer.FormClosed
+= new System.Windows.Forms.FormClosedEventHandler(rangeExplorer_FormClosed);
// Display the Range Explorer to the user.
explorer.Show(workbookView);
In the FormClosed event handler, you can get the NumberFormat for anywhere inside the range used in the RangeExplorer constructor. If your text box is called textbox1, it would look like this.
private void rangeExplorer_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e)
{
workbookView.GetLock();
try
{
SpreadsheetGear.IWorksheet worksheet = workbookView.ActiveWorksheet;
textbox1.Text = worksheet.Cells["A1"].NumberFormat;
}
finally
{
workbookView.ReleaseLock();
}
}

Resources