While typing the previous email, I was thinking of creating my own Field
to do this, so here we go: a PlainText field. Included if anyone needs.

Cheers,

WarnerJan


import org.apache.click.control.Field;
import org.apache.click.util.HtmlStringBuffer;

public class PlainText extends Field {

    private String text;

    public PlainText() {
        this.text = "";
    }

    public PlainText(String text) {
        this.text = text;
    }

    public String getLabel() {
        return text;
    }

    public void setLabel(String label) {
        this.text= label;
    }

    public String getValue() {
        return text;
    }

    public void setValue(String value) {
        this.text = value;
    }

    public Object getValueObject() {
        return text;
    }

    public void setValueObject(Object object) {
        this.text = object== null ? "" : object.toString();
    }

    public void render(HtmlStringBuffer buffer) {
        buffer.append(text);
    }
}





On Tue, 2009-04-14 at 14:32 +0200, WarnerJan Veldhuis wrote:

> Hi list,
> 
> I am using a FormTable with FieldColumns. If I set the FieldColum to
> use a Label as a field, the value is not rendered, but the name is.
> Digging into the source shows why: the Label renders the label only
> (not the valueobject). If the label is not set, the name is rendered.
> (Field#getLabel() ). As this may sound logical, this behaviour is not
> working well in FieldColumns. The FieldColumn will set the valueobject
> to whatever getProperty(Object row) returns. When done on a Label,
> that value gets ignored. 
> 
> If I change the Field in FieldColumn to TextField instead of Label the
> code works as expected. (Needless to say I don't need a textbox here,
> just plain text). Setting the field to NULL in FieldColumn will
> generate a NPE, even though FieldColumn allows NULL for field:
> 
> FieldColumn.java#renderTableDataContent(Object, HtmlStringBuffer,
> Context, int)
> if (field == null) {
>   super.renderTableDataContent(row, buffer, context, rowIndex);
>   return;
> }
> 
> 
> What can I use in FieldColumn to show plain text? And are my
> expectations correct, and is a bug born?
> 
> Cheers,
> 
> WarnerJan

WarnerJan Veldhuis

QPR CostControl BV
Clarissenhof 15
4133 AB Vianen
Tel: +31(0)347 355023
Helpsdesk: +31(0)347 355027


Reply via email to