Populate spreadsheet from external database according to select box value

Confluence User - 20 Nov, 2018

Hello,

I'm working with an external database.

I succeeded importing fields for a select box creating my own FormOptionsBinder plugin.

Now I want to populate a spreadsheet (possibly in an Ajax subform if it helps) according to the selected value.

I think I have to create my own load binder for this purpose, but I can't find which class I must inherit from or which interfaces I must implement. Do you have any examples of spreadsheet load binders?

Regards,

Raphaël

spreadsheet;loadbinder;plugin

3


21 Nov, 2018
confluenceUser
1
confluenceUser

Hello,

I ended up using this, which works : 

 
public class IcaosListAjaxFormBinder extends FormBinder implements FormLoadBinder, FormLoadMultiRowElementBinder {

public FormRowSet load(Element element, String primaryKey, FormData formData) {

FormRowSet names = new FormRowSet();

 String processId = formData.getProcessId();

if (primaryKey != null && processId!= null && !primaryKey.equals(processId)) {
            //primaryKey != processId on AJAX loading because
//primaryKey == manualName on AJAX loading

 RawPagesDao rawpagesdao = (RawPagesDao) AppContext.getInstance().getAppContext().getBean("rawPagesDao");

 Set<String> dataFromDB = rawpagesdao.getDatasFromManual(formData.getProcessId(), primaryKey);

 FormRow dataEntry = new FormRow();
 JSONStringer datasList = new JSONStringer();
try {
datasList.array();

for (String dataName : dataFromDB) {
datasList.object().key("dataName").value(dataName).key("selected").value(false).endObject();
 }

datasList.endArray();

 dataEntry.put("generationRequirementsNames", datasList.toString());
 } catch (JSONException ex) {
LogUtil.error(getClassName(), ex, String.format("Encountered a JSON error: %s", ex.getMessage()));
 }

names.add(dataEntry);
 }

return names;
 }

//Add overriding stuff here
}

Regards,

Raphaël

21 Nov, 2018
confluenceUser
confluenceUser

That's great, thanks for sharing your solution!

21 Nov, 2018
confluenceUser
confluenceUser

You're welcome, but do you know how to format code in a pretty way?

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print