[opencms-dev] OAMP Form question?
Mathias Lin | SYSVISION
mail at mathiaslin.com
Sat Apr 11 11:53:04 CEST 2009
Mathias Lin | SYSVISION wrote:
>
> Furthermore I found that only text and textarea input fields resolve the
> macros in the default values properly, if I use checkbox or radio, the
> macros aren't resolved at all. Why?
>
Regarding this issue, we have fixed the problem by adjusting the jsp
template
/system/modules/com.alkacon.opencms.formgenerator/pages/form.jsp
lines 85ff. (which should probably be moved into the Java classes, but we
just tried this for a quick fix directly in the jsp for now):
[...]
// loop through all form input fields
I_CmsField field = (I_CmsField)fields.get(i);
// --- Begin: SYSVISION modification ---
List items = new ArrayList();
CmsMacroResolver macro =
CmsMacroResolver.newInstance().setCmsObject(cms.getCmsObject());
Iterator it = field.getItems().iterator();
while (it.hasNext()) {
CmsFieldItem curOption = (CmsFieldItem)it.next();
if (CmsMacroResolver.isMacro(curOption.getValue())){
String value =
macro.getMacroValue(CmsMacroResolver.stripMacro(curOption.getValue()));
items.add(new CmsFieldItem
(value,value,curOption.isSelected(),curOption.isShowInRow()));
} else {
items.add(curOption);
}
}
field.setItems(items);
// --- End: SYSVISION modification ---
if(i==n-1)place=1; //the last one must close the tr
[...]
Mathias Lin | SYSVISION wrote:
>
> So probably we need to use the DynamicField?! In this regard, it doesn't
> get clear to me: if I choose "Dynamic" as the field type instead of "Text"
> or "Radio", how does the form know, which input widget to display (text
> input or radio, or any other?). I can see that there's an attribute in the
> class CmsDynamicField named 'TYPE', but how does it's value get set?
> There's no option in the form where to choose the type of the DynamicField
> other than 'dynamic' ?
> Do I need to set it in the DynamicFieldResolver? If so, how?
>
This is the code of the DynamicFieldResolver implementation; but the field
still just doesn't get rendered when displaying the form.
package com.company.intra.controller.formgenerator;
import com.alkacon.opencms.formgenerator.CmsDynamicField;
import com.alkacon.opencms.formgenerator.CmsForm;
import com.alkacon.opencms.formgenerator.I_CmsDynamicFieldResolver;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class CmsDynamicFieldResolver implements I_CmsDynamicFieldResolver {
protected final Log logger =
LogFactory.getLog(CmsDynamicFieldResolver.class);
public String resolveValue(CmsDynamicField field, CmsForm form) {
logger.info("DYNFIELD field.getType(): " + field.getType() );
// just for debugging - these values are already set in the webform
config itself
field.setLabel("TEST");
field.setMandatory(true);
field.setValue("whatever");
return "My value";
}
}
-----
Mathias Lin
SYSVISION Ltd., China
http://www.sysvision.com
--
View this message in context: http://www.nabble.com/OAMP-Form-question--tp18709090p22999540.html
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
More information about the opencms-dev
mailing list