insert view wnels2  2009-05-06 13:14
Status: Closed
 
Sorry for all of the questions but I'm almost done.
I want a column in an insert form to contain a value but be hidden or readonly (preferably readonly).
When I am successful in making the field readonly it won't bind the value of that field to the table's model bean. I've tryed variations of the following code.
 
 private DataRegion getMyDataRegion()
    {
        DataRegion rgn = new DataRegion();
        TableInfo tableInfo = MySchema.getInstance().getTableInfoMy();
        List<ColumnInfo> columns = tableInfo.getColumns("MyId, field1, field2");
        //the value for MyId is set after the dataregion is returned.
        //columns.get(0).setUserEditable(false); Works but doesn't bind value to bean
        //columns.get(0).setIsHidden(true ); Doesn't seem to do anything?
        //columns.get(0).setIsUnselectable(true); Doesn't seem to do anything?
        //columns.get(0).setReadOnly(true); Works but doesn't bind value to bean
        rgn.setColumns(columns);
        ActionButton button = new ActionButton("myaction.post", "Submit");
        button.setActionType(ActionButton.Action.POST);
        rgn.setButtonBar(new ButtonBar().add(button ));

        return rgn;
    }

Thanks,
Bill
 
 
wnels2 responded:  2009-05-08 08:48
I tried columns.get(0).setCssStyle("display:none;");
and columns.get(0).setCssStyle("visibility:hidden;");
But these also had no effect.
Thanks,
Bill
 
adam responded:  2009-05-08 09:04
You can use DataRegion.addHiddenFormField() for this.
 
wnels2 responded:  2009-05-08 11:14
Adam, Thanks!
I had tried that before but messing with it some more I found that even though I am setting the column name as "ProdId" the hidden field name needs to be "prodId".

Have a great weekend.
Bill