The FormItem is not visible in the SmartClient Version: v10.1p_2016-06-16/PowerEdition Deployment (built 2016-06-16) , but works just fine in the version 5.0.
The private
is not visible, but if I change it to
it works just fine and the item is visible.
to call the window just call it this way:
The problem is the SmartGWT/5.1p/PowerEdition , but works just fine in the 5.0p.
Code:
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.RecordList;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import java.util.LinkedHashMap;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.Record;
import com.smartgwt.client.data.RecordList;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.FormItem;
import com.smartgwt.client.widgets.form.fields.HiddenItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.layout.HLayout;
public class NotificationWindow extends Window{
final private static int WINDOW_WIDTH = 450;
final private static int WINDOW_HEIGHT = 200;
final private static int NUM_COLUMNS = 2;
final private static int COLUMN_WIDTH = 200;
final private static int PADDING = 10;
final private IButton cancelButton = new IButton( "cancel" );
final private DynamicForm form = new DynamicForm();
private SelectItem typeField; // global to allow hide/show/disable throughout code
private final HiddenItem hiddenTypeItem = new HiddenItem( "alert_policy_type_id" );
private RecordList recordList;
/**
* If non-null, contains an existing notification policy record that is to be used as a base for cloning into the
* new record being created.
*/
private Record cloneRecord = null;
public NotificationWindow() {
super();
}
/**
* Instantiates a new notification window. This constructor is used for cloning and existing record.
*
* [USER="45788"]param[/USER] cloneRecord the clone record
*/
public NotificationWindow( final Record cloneRecord ) {
super();
this.cloneRecord = cloneRecord;
}
public void doCreate( final RecordList recordList ) {
this.initLayout( recordList );
this.show(); // [**ERROR**]
}
private void initLayout( final RecordList recordList ) {
this.recordList = recordList;
this.setIsModal( true );
this.setShowModalMask( true );
this.setWidth( NotificationWindow.WINDOW_WIDTH );
this.setHeight( NotificationWindow.WINDOW_HEIGHT );
this.setShowMinimizeButton( false );
this.setShowMaximizeButton( false );
this.setShowCloseButton( false );
this.setDismissOnEscape( false );
this.addItem( this.getForm() );
this.addItem( this.getButtons() );
this.centerInPage();
this.form.clearValues();
this.setTitle( "TITLE" );
this.setKeepInParentRect( true );
this.form.editNewRecord();
if ( this.cloneRecord != null ) {
this.typeField.setValue( this.cloneRecord.getAttribute( "alert_policy_type_id" ) );
this.typeField.setDisabled( true );
} else {
this.typeField.setDisabled( false );
}
}
private Canvas getButtons() {
this.cancelButton.addClickHandler( new ClickHandler() {
@Override
public void onClick( final ClickEvent event ) {
NotificationWindow.this.returnAndClose( null );
}
} );
final HLayout l = new HLayout();
l.setLayoutAlign( Alignment.CENTER );
l.setLayoutMargin( NotificationWindow.PADDING );
l.setMembersMargin( NotificationWindow.PADDING );
l.setAlign( Alignment.CENTER );
l.setWidth100();
l.setHeight( "20%" );
final Canvas spacer = new Canvas();
spacer.setWidth100();
l.addMember( this.cancelButton );
return l;
}
private void returnAndClose( final Record record ) {
NotificationWindow.this.hide();
NotificationWindow.this.markForDestroy();
}
private final FormItem name = new FormItem( "alert_policy_name" );
private DynamicForm getForm() {
//this.form.setDataSource( this.dsPolicySummary );
this.form.setCellPadding( NotificationWindow.PADDING );
this.form.setWrapItemTitles( false );
this.form.setWidth( "*" );
this.form.setNumCols( NotificationWindow.NUM_COLUMNS );
this.form.setHeight( "80%" );
final FormItem id = new FormItem( "alert_policy_id" );
this.name.setWidth( NotificationWindow.COLUMN_WIDTH );
this.name.setRequired( true );
this.name.setTitle( "policy_name" );
//this.name.setValidators( new UniqueValidator( new ValidationInfo( this.recordList, null, null ) ), new RequiredValidator() );
this.typeField = new SelectItem( "temp_type_id" );
this.typeField.setWidth( NotificationWindow.COLUMN_WIDTH );
this.typeField.setRequired( true );
this.typeField.setTitle( "alert_viewPolicySummary_title_alert_type_description" );
LinkedHashMap< Integer, String > map = new LinkedHashMap< Integer, String >();
map.put( 1, "describePolicyType1" );
map.put( 2, "describePolicyType2" );
this.typeField.setValueMap( map );
this.form.setFields( id, this.name, this.typeField, this.hiddenTypeItem );
id.setVisible( false );
return this.form;
}
}
Code:
final FormItem name = new FormItem( "alert_policy_name" );
Code:
final FormItem name = new TextItem( "alert_policy_name" );
to call the window just call it this way:
Code:
final DynamicForm form = new DynamicForm();
final IButton button = new IButton("Hello");
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final NotificationWindow notifWindow = new NotificationWindow();
notifWindow.doCreate(null);
}
});
Comment