public abstract class Hidden extends AbstractFormComponent
{
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
{
IForm form = getForm(cycle);
boolean formRewound = form.isRewinding();
String name = form.getElementId(this);
// If the form containing the Hidden isn't rewound, then render.
if (!formRewound)
{
// Optimiziation: if the page is rewinding (some other action or
// form was submitted), then don't bother rendering.
if (cycle.isRewinding())
return;
String externalValue = null;
if (getEncode())
{
Object value = getValueBinding().getObject();
try
{
externalValue = getDataSqueezer().squeeze(value);
}
catch (IOException ex)
{
throw new ApplicationRuntimeException(ex.getMessage(), this, null, ex);
}
}
else
externalValue = (String) getValueBinding().getObject("value", String.class);
String id = getElementId();
//if we would like to test the IForm.addHiddenValue(name, externalValue) method with
//Hidden JUnit test the following code must be default. But from the performance issue
//I don't use the id parameter clauses.
/* if(id == null || id.length() == 0){
form.addHiddenValue(name, externalValue);
}else{
form.addHiddenValue(name, id, externalValue);
}
*/
form.addHiddenValue(name, id, externalValue);
return;
}