1 16 package org.apache.cocoon.forms.datatype; 17 18 import org.apache.avalon.framework.context.Context; 19 import org.apache.avalon.framework.context.ContextException; 20 import org.apache.avalon.framework.context.Contextualizable; 21 import org.apache.cocoon.forms.FormsConstants; 22 import org.apache.cocoon.forms.util.DomHelper; 23 import org.w3c.dom.Element ; 24 25 import java.util.Map ; 26 27 51 public class FlowJXPathSelectionListBuilder implements SelectionListBuilder, Contextualizable { 52 53 private Context context; 54 55 public void contextualize(Context context) throws ContextException { 56 this.context = context; 57 } 58 59 public SelectionList build(Element selectionListElement, Datatype datatype) throws Exception { 60 61 String listPath = DomHelper.getAttribute(selectionListElement, "list-path"); 62 String valuePath = DomHelper.getAttribute(selectionListElement, "value-path"); 63 Map nspfx = DomHelper.getInheritedNSDeclarations(selectionListElement); 64 String i18nPfx = FormsConstants.I18N_PREFIX; 65 if (nspfx != null) { 66 i18nPfx = (String )nspfx.get( FormsConstants.I18N_NS ); 67 if (i18nPfx == null ) { 68 i18nPfx = FormsConstants.I18N_PREFIX; 69 } 70 } 71 String labelPath = DomHelper.getAttribute(selectionListElement, "label-path", null); 72 boolean labelIsI18nKey = false; 73 if( labelPath == null ) 74 { 75 labelPath = DomHelper.getAttribute(selectionListElement, i18nPfx + ":label-path"); 76 labelIsI18nKey = true; 77 } 78 String nullText = DomHelper.getAttribute(selectionListElement, "null-text", null); 79 boolean nullTextIsI18nKey = false; 80 if( nullText == null ) { 81 nullText = DomHelper.getAttribute(selectionListElement, i18nPfx + ":null-text", null); 82 if( nullText != null ) { 83 nullTextIsI18nKey = true; 84 } 85 } 86 87 String i18nCatalog = DomHelper.getAttribute(selectionListElement, "catalogue", null); 88 89 90 return new FlowJXPathSelectionList(context, 91 listPath, 92 valuePath, 93 labelPath, 94 datatype, 95 nullText, 96 nullTextIsI18nKey, 97 i18nCatalog, 98 labelIsI18nKey); 99 } 100 101 } 102 | Popular Tags |