My fxml contains a TextField, a ComboBox, a DatePicker and a Button that should only be enabled when the objects above are not empty.
#FXML private TextField numText;
#FXML private ComboBox societeComboBox;
#FXML private DatePicker dateCreationPicker;
#FXML private Button ajoutBtn;
i figured out how to bind the disable property of the button to the TextField but i can't figure out how to do the same for the ComboBox and the DatePicker.
ajoutBtn.disableProperty().bind(
Bindings.isEmpty(numText.textProperty()) );
Both the ComboBox and the DatePicker have valueProperty that can be used for checking their emptiness. You can OR them to disableProperty of the button
ajoutBtn.disableProperty().bind(
numText.textProperty().isEmpty()
.or( societeComboBox.valueProperty().isNull() )
.or( dateCreationPicker.valueProperty().isNull() ) );
Related
DatePicker behavior in view: In a Vaadin 23 application there is a view with two DatePickers and a button:
When a user steps between the fields with TAB, then the DatePicker marks the whole content as selected (which is fine and the intended behavior):
DatePicker behavior in Dialog is different: When I put two DatePicker instances into a Dialog then the TAB behavior is different: it does not mark the whole content, but sets the focus after the content:
Code:
#Route("sandbox")
public class SandboxView extends VerticalLayout {
public SandboxView() {
this.add(createDatePicker(), createDatePicker());
this.add(new Button("Open dialog", event -> {
openDialog();
}));
}
private void openDialog() {
VerticalLayout layout = new VerticalLayout(createDatePicker(), createDatePicker());
Dialog dialog = new Dialog(layout);
dialog.open();
}
private DatePicker createDatePicker() {
DatePicker datePicker = new DatePicker();
datePicker.setValue(LocalDate.now());
datePicker.setAutoOpen(false);
return datePicker;
}
}
Intended behavior: I'd like the DatePicker to show the same behavior in a Dialog as it is in a view.
Question: How can I do this?
What I tried: When a focus listener calls select() at the INPUT child node in JavaScript (see code below), the whole content is marked/selected (which is as intended). But this also marks/selects the whole content when the user clicks with the mouse into the field (which is not intended).
field.getElement().addEventListener("focus", new DomEventListener() {
#Override
public void handleEvent(DomEvent event) {
event.getSource().executeJs("for (var i=0;i<$0.childNodes.length;i++){if($0.childNodes[i].nodeName=='INPUT'){$0.childNodes[i].select();}}");
}
});
Update for TextField: When using TextFields instead of DatePickers, it's the same behavior: in a view a TAB marks/selects the whole content. In a Dialog a TAB sets the focus before the content, but does not mark/select it:
This behavior is fixed in Vaadin 23.1.6.
I use the menuBar component in my application and I would like to add a "mini" form in the menu.
In the "contact" menu, the user can fill a TextField with a phone number and click on a submit button to be called.
My issue is when I select the TextField, the menu closes automatically.
Do you know if it's possible to do that and how I can do ?
Thank you.
This an example of my menu
public class HeaderView extends MenuBar implements RouterLayout {
private final MenuItem tools;
private final MenuItem contacts;
public HeaderView() {
// logo
final Image img = new Image("img/logo.png", "image");
img.setHeight("44px");
this.addItem(img);
// TOOLS
tools = this.addItem("Tools");
tools.addComponentAsFirst(new Icon(VaadinIcon.TOOLS));
// CONTACTS
contacts = this.addItem("Contacts");
contacts.addComponentAsFirst(new Icon(VaadinIcon.PHONE));
// layout for the form contact
final FormLayout nameLayout = new FormLayout();
final TextField phoneField = new TextField();
phoneField.setLabel("Phone");
phoneField.setPlaceholder("Phone");
final Button sendButton = new Button("send");
// add textfield and button to the layout
nameLayout.add(phoneField, sendButton);
// add the form to the menubar
contacts.getSubMenu().addItem(nameLayout);
}
You can try changing contacts.getSubMenu().addItem(nameLayout) to contacts.getSubMenu().add(nameLayout) I'm not sure if you can self trigger closure of the submenu after submission. If that is required.
I have a Custom component with a textField and a button, I want to onClick (of the Button), get the text from the textField and call another Component.
The error I get when I call mainLayout.addComponent(new A(textField.getValue()); is an
java.lang.IllegalStateException: Composition root must be set to non-null value before the com.example.vaadpro.
As the exception says, you have to call setCompositionRoot for your CustomComponent:
public class A extends CustomComponent {
HorizontalLayout layout = new new HorizontalLayout();
public A() {
layout.add(new Label("Hello world!"));
layout.add(new Button("Click me!"));
setCompositionRoot(layout); // This is needed!
}
}
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()
I am a new BB developer working on android simultaneously, I am preparing a project containing list and object choice fields in both the languages.
In blackberry, I have a list of 10 elements and on each element row I need to show an arrow button on click of that button a ObjectChoiceField will pops up.
Here, it is clear that the list and obejctchoice field both are custom.
I am very confused please let me know, how this can be achieved.
Thanx in advance..!:|
// customize ListField
How to customize a ListField in BlackBerry?
To get clicked item just add below function to code
protected boolean navigationClick(int status, int time) {
Field field = this.getLeafFieldWithFocus();
if(field instanceof ListField){
System.out.println("navigationClick Yes Yes you clicked list item ");
ListField listField = (ListField)field;
// this will give you clicked index.
int index = listField.getSelectedIndex();
// pop up your Object choice field here...
}
return true;
}