Will,
That seems pretty cool - care to drop that somewhere on the wiki, for
example ?
-g
On Oct 7, 2008, at 5:51 PM, Will Scheidegger wrote:
I've written two custom controls which allow the user to select
values from the data module. One produces a "select" control
(extending DialogSelect), the other a list of checkboxes (extending
DialogButtonSet). In both cases its not really rocket science.
Here's the code for the "QuerySelect" control which gets its options
by querying the data module. As you can see, you can either
configure it to get the nodes from a specific path or you can even
provide an arbitrary query string.
Hope this will help you to get started.
Cheers,
will
public class QuerySelect 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;
}
}
On 07.10.2008, at 14:14, Matteo Pelucco wrote:
Leviter ha scritto:
No... nothing found. So I still do not have any solution for
this. :-((
If you think of something I am still very interested in it!
One idea can be:
1. use a "includeDialog" (jsp based)
2. into the JSP:
a. load configuration you need
b. load data module with your keywords
c. extract keywords and build an array (for instance..)
3. build a multi-control (html multiple value select, a list of
checkboxes..) and populate with your extracted keywords
4. save user-selected keywords in a String (comma/space separated).
5. when you go in edit mode you do from point 1 to 4, but you must
preselect the keywords previously selected..
The only problem I see is to keep consistence between data module
and all your paragraphs...
HTH,
Matteo
----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/
----------------------------------------------------------------
----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/
----------------------------------------------------------------
----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/
----------------------------------------------------------------