My onclick event gets interrupted by button action (full submit). Any ideas?
An alternative would be to change the h:commandButton to a4j:commandButton, but I need a full submit in order for the button to work correctly like this.
<h:commandButton onclick="trackClick();" action="#{bean.print}" />
Related
I have tried to do some research on the topic and I am attempting to add an on-click listener for a button in a fragment in the main activity. So when I click a button in a fragment the click can get registered in the main activity file.
You can use custom broadcast receiver
You will register a receiver on button click in fragment
Then in activity apply action if this broadcast action equal to this custom action
you can use interface for this problem
So I'm trying to make a kind of Wheel of Fortune game or Hangman. I have 33 buttons which represent the alphabet, 1 button = 1 letter. When a user presses one, it has to 'dissapear' (become disable and invisible). I created all the buttons in the SceneBuilder so they are located in the FXML file.
How do I actually do that? I created this method for the first button. But it doesn't work properly, no matter what button I press the first one dissapear. Is there an easier way to do it wIthout writing 33 different methods for each button?
public void letterChosen (ActionEvent evt) {
b1.setDisable(true);
b1.setVisible(false);
The Button that was clicked is available as the source of the ActionEvent.
Additionally userData could be attached to the Button, in case you cannot get the necessary information to handle the button click from other properties of the Button:
public void letterChosen(ActionEvent event) {
Button source = (Button) event.getSource();
source.setVisible(false);
System.out.println("pick: "+source.getUserData());
}
FXML
<Button onAction="#letterChosen" userData="a" text="A"/>
<Button onAction="#letterChosen" userData="b" text="B"/>
Note that it isn't necessary to disable a Node that isn't shown, since a Node that is not visible cannot be interacted with. a disabled Button will appear "faded" by default, but could also be shown differently, e.g. using CSS.
My button on zul file using MVVM.
<button id="ok" label="OK" onClick="#command('vm.myCommand')"/>
my vm
#Command
public void myCommand(){
System.out.println('my command clicked');
}
It display twice when I double click on my button. How to prevent this?
use autodisable attribute of button please have a look below code.
<zk>
<button id="ok" label="OK" autodisable="self" />
</zk>
You can run this code in zk Fiddle .When you click on button it automatically disable itself and when action is done it enable again.
Not related to your concrete problem but ZK Progree Bar another option to prevent user click after any action performed by user.
Action myAction= new Action("LABEL", ImageCache.getImageDescriptor("IMAGE"));
This code shows me a button without any text. Instead it only shows the image.
What should I do to display them both side by side?
I tried using setText() and setDescription() and setImageDescriptor() but none helped.
Text is not normally shown for an action in a ToolBar if there is also an image.
If you are adding the Action to the tool bar manager using an ActionContributionItem you can call ActionContributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
I have a text box with a valuechange handler :
#UiHandler("box")
public void box_onValueChange(ValueChangeEvent<String> event) {
window.alert("allright");
}
It works great if i lose focus by clicking elsewhere. Except when i click on a button.
Is there a trick i didn't see ? Should i hack my onclick event to fire the valuechangeevent anyway ?
Thanks