Hi,
In Magnolia 5.4, do you have any idea how to build a Select box from a SQL JCR
query?
In 4.4, this is what we used to do:
[code]package com.mycompany.gui.dialog
import info.magnolia.cms.gui.dialog.*;
import javax.jcr.*;
public class DialogQuerySelect extends DialogSelect {
protected Collection getOptionNodes(Content configNode) {
String repository = this.getConfigValue("repository", "data");
String itemType = this.getConfigValue("itemType", "nt:base");
String path = this.getConfigValue("path", "");
String query = this.getConfigValue("query");
String type = this.getConfigValue("type", "sql");
String queryString;
if (query != null && query.length() > 0) {
queryString = query;
} else {
type = "sql";
queryString = "SELECT * FROM " + itemType + " WHERE jcr:path LIKE '"
+ path + "/%'";
}
Collection items = QueryUtil.query(repository, queryString, type,
itemType);
Collection configItems;
try {
configItems = super.getOptionNodes(configNode);
items.addAll(configItems);
} catch (PathNotFoundException ex) {
Logger.getLogger(QuerySelection.class.getName()).log(Level.SEVERE,
null, ex);
} catch (RepositoryException ex) {
Logger.getLogger(QuerySelection.class.getName()).log(Level.SEVERE,
null, ex);
}
return items;
}
}[/code]
I think the solution is around
info.magnolia.ui.form.field.factory.SelectFieldFactory (and especially
buildRemoteOptions)
but how to execute a SQL Query instead of accessing a JCR from a repo/path?
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=c862ee65-c31a-4123-a7d0-ca14dec2dd88
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------