} catch(ComponentClassNotFoundException cnfe) {
return "<br><b><font color=\"red\">"
+ labels.getLabel("edited_component_class_not_found") + "</font></b><br>";
}
ElementContainer content = new ElementContainer().addElement(new BR()).addElement(
new H1()
.addElement(component.getName()));
content.addElement(new HR());
if( component instanceof GUIConfigurationIF) {
GUIContext guiContext = ((GUIConfigurationIF) component).getGUIContext();
if(guiContext != null) {
// Component might have it's own labels...
LabelResource customLabelResource = PipeComponentUtils.getCustomLabelResource(new Locale(
environment.getLanguage(session)), labels, component.getClass());
Map fields = guiContext.makeFields(component, customLabelResource, req);
// -----------
// Handle post
// -----------
if(requestType == POST_REQUEST && parameters.wasGiven(ACTION)) {
int action = parameters.getInt(ACTION);
if(action == 1) {
if(guiContext.hasBeenEdited(fields)) {
guiContext.commitFields(fields);
//System.out.println("Saving PipeComponentData, ID: " + componentData.getId());
pers.update(componentData);
}
} else
guiContext.revertFields(fields);
}
// -----------------------
// Print the field editors
// -----------------------
String guiHtml;
// Use template if the component provides one
String templateStr = ((GUIConfigurationIF) component).getGUITemplate();
if(templateStr != null) {
Template template = Template.createTemplate(templateStr);
guiContext.writeEditors(fields, template);
template.write();
guiHtml = template.toString();
}
// Else just print them...
else {
guiHtml = new String();
for(Iterator i = fields.values().iterator(); i.hasNext();) {
Field field = (Field) i.next();
guiHtml += field.getEditor();
}
}
// Create a back button to the Pipe Editor
Long pipeId = (Long) session.getAttribute(PIPE_ID_SESSION_KEY);
Input backButton = new Input(Input.BUTTON,
"bb", labels.getLabel("back_to_pipe_editor"));
backButton.setOnClick("document.location='EditPipe?pipeid=" + pipeId + "'");
Form form = getFormWithCustomButton("EditComponent",
guiHtml, backButton, labels, false, true);
// Insert hidden fields carrying component and data IDs
form.addElement(parameters.getInput(Input.HIDDEN, COMPONENT_ID));
form.addElement(parameters.getInput(Input.HIDDEN, DATA_ID));
content.addElement(form);
}
}
else
content.addElement(labels.getLabel("no_attributes_to_edit"));
return content.toString();
}