How to remove title fields in form design caption in Dynamics AX? - field

I open form with menuitembutton and in caption are visible title fields from datasource. Can I remove it? This form should be for creating new records and this title fields can be confusing.
In my case title bar is not replaced with text "New record". But I insert in run() method line Table_ds.create() and change in menuitem properties EnumTypeParameter, EnumParameter to value "FormOpenMode"

Some additional methods. You can change the caption a couple of ways.
Override the form's init method and this will work, but still leaves the (TitleField1, TitleField2) at the end of the caption.
public void init()
{
super();
element.design().caption("New Caption");
}
Alternatively, override the form's run() method and do something like this:
public void run()
{
super();
WinAPI::setWindowText(this.hWnd(), "New Caption without other stuff");
}

The title fields can be removed from the form title bar by clearing the TitleDatasource property of the form's design node.
Note that when a new record is created, the title fields in the form title bar will be replaced with the text "New record".

Related

Show/hide SelectItem in SmartGWT

Hi all first of all I´m noob using SmartGWT, I have a SelectItem component with setVisible(false) and added into a DynamicForm. This DynamicForm is added into a Layout. I need to set the SelectItem with visible to true when another component is changed.
I do this:
SelectItem -> setVisible(true);
DynamicForm -> .redraw();
Layout -> .redraw();
Following piece of code works, and toggles the visibility of SelectItem on button click.
However note that this could lead to a jumpy UI, as other form controls flow in and out to fill the gap.
A better approach would be to enable/disable the component as indicated in the comment, which does not require a redraw.
final DynamicForm form = new DynamicForm();
form.setWidth100();
form.setHeight100();
final SelectItem selectItem = new SelectItem("sel", "Select");
selectItem.setValueMap("First", "Second", "Third");
ButtonItem buttonItem = new ButtonItem("btn", "Set");
buttonItem.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
selectItem.setVisible(!selectItem.getVisible());
form.redraw();
// uncomment following two lines and comment above two lines to enable/disable
// boolean isDisabled = Boolean.TRUE.equals(selectItem.getDisabled());
// selectItem.setDisabled(!isDisabled);
}
});
form.setFields(selectItem, buttonItem);
Other ways to handle form layouts:
http://www.smartclient.com/smartgwt/showcase/#layout_form_sections
http://www.smartclient.com/smartgwt/showcase/#layout_form_splitting

How to make a blackberry BitmapField non focusable in runtime

How to make a blackberry BitmapField non-focusable in runtime? I want make it dimmed based on a certain event.
Extend the BitmapField to override the isFocusable() method like this:
public class FocusableBitmapField extends BitmapField {
//Default value depending on whether you want it that way.
private boolean focusable = true;
public boolean isFocusable() {
return focusable;
}
public boolean setFocusable(boolean focusable) {
this.focusable = focusable;
}
}
Most of times this works:
field.setEditable(false);
You can also create a non-focusable field by passing the style flag Field.NON_FOCUSABLE or Field.FOCUSABLE to the constructor, but once instantiated you cannot change it's focusable state. Even if you could, then the field won't look "dimmed" or "disabled", but simply the focus will jump to the next focusable field after it. An example of this are non-focusable label fields.
UPDATE: This would work for built in fields like EditFields, Checkbox, RadioButtons, etc. In your case, this does not work since a BitmapField is not "editable", it's a read only field. You can make a trick like #adwiv answer shows, but the "disabled" or gray overlay you'll have to implement it yourself.

How can I retrieve label text from ListBox in mosync?

I am using mosync 3.1.
I have created a listbox and added labels as listbox items. I want to be able to retrieve the text or name of the label that is selected.
You should implement a "ItemSelectedListener" class and override the virual "itemSelected" method as this:
virtual void itemSelected (ListBox *sender, Widget *selectedWidget, Widget *unselectedWidget)
and then use this ListBox method:
"void addItemSelectedListener (ItemSelectedListener *listener)"
When an item selected in ListBox, the "itemSelectd" method has been called with "selected widget". Then you can get a text:
((Label*)selectedWidget)->getText()

Hiding all default menu items in blackberry

I had to remove all the default menus in blackberry. I have used the following code
protected void makeMenu(Menu menu, int instance) {
// if you want default menu items, uncomment bellow line
// super.makeMenu(menu, instance);
}
But after this, still it was showing the default menu like "Switch Application", for that i have used super(NO_SYSTEM_MENU_ITEMS) in the screen class constructor.
Now all menus are removed, but it is still showing "empty menu" as shown in the image below.
Please let me know how could we remove all menu items and make it empty?
try this in your main screen
public boolean onMenu(int instance) {
// TODO Auto-generated method stub
return false;
}
You can also do that.
public boolean onMenu(int instance) {
return super.onMenu(2);
}
Because for creating menu instance value is 0. So, for any non zero value it doesn't create the menu.

Vaadin addStyleName problem

I created a TextField with TextChangeListener. When user types in certain values (in this case 'admin') then addStyleName is invoked on that field and font color becomes red. But afterwards, the value is blank and each entered character is being cleared.
Here is the code of the application. Why after adding new style to TextField its value changes?
public class VaadintestApplication extends Application {
#Override
public void init() {
Window mainWindow = new Window("Vaadintest Application");
setTheme("test");
TextField textField = new TextField("username");
textField.setEnabled(true);
textField.setTextChangeEventMode(TextChangeEventMode.EAGER);
textField.addListener(new TextChangeListener() {
public void textChange(TextChangeEvent event) {
if ("admin".equals(event.getText())) {
((TextField) event.getComponent()).addStyleName("text-error");
} else {
((TextField) event.getComponent()).removeStyleName("text-error");
}
}
});
mainWindow.addComponent(textField);
setMainWindow(mainWindow);
}
}
I would guess that the following happens:
The style name change triggers a repaint on the server, causing the TextField component to be serialized again to the client
The client receives the serialization (the whole bloody thing, not just the changed parts, because that's how things work with Vaadin), and hence it changes the contents of the textfield, while ignoring any changes that are pending from the text change listener
Solutions:
Update the value of the TextField at the same time you add/remove the style name: ((TextField) event.getComponent()).setValue(event.getText())
Create a custom client side widget which extends VTextField and add the functionality there

Resources