PRIME FACES ("commandButton"):

7

**

How should I implement the code or what is the property of the "Command Button" so that it can only be executed by clicking on it ??

**

I have the following code in which I use Primer faces the "command Button" which is at the beginning of the form, and when I am filling in the other fields of the form it runs without clicking or being on top of the button, someone who knows or can you help me how to make the action of the button only run when you click on this button or any property that will help me with this case? .. Thank you very much in advance for the help.

The code of the commandButton is as follows:

  <div class="centerButton">
            <p:commandButton 
                action="Ejecuccion" 
                icon="ui-icon-person" 
                value=" Ejecutar sentencia"  process="@this" >
            </p:commandButton>    
        </div>
    
asked by Alexander 16.01.2018 в 18:50
source

3 answers

0

What you can do is put a property called immediate that has these buttons to be able to process only the action of the button also if you want to update only a part of the form you use update=" name of the component to update "

<div class="centerButton">
        <p:commandButton 
            action="Ejecuccion" 
            icon="ui-icon-person" 
            value=" Ejecutar sentencia"  process="@this" 
           immediate="true">
        </p:commandButton>    
    </div>
    
answered by 16.01.2018 в 20:39
0

As when using the "commandButton" of "Prime faces" this executes execution (the first commandButton that is in the form) whenever you press enter then the solution that I found provisionally was to create a command button that does nothing and does not affect the proper functioning of the code or process:

     <div class="centerButton">
            <p:remoteCommand name="find" action="Usuario"
                immediate="true">
            </p:remoteCommand>
            <h:commandButton image="/images/blanco.png"
                styleClass="iconAcciones" immediate="true">
                <p:ajax event="click" oncomplete="findUsuario()" />
            </h:commandButton>
        </div>
      <div class="centerButton">
        <p:commandButton 
            action="Ejecuccion" 
            icon="ui-icon-person" 
            value=" Ejecutar sentencia"  process="@this" >
        </p:commandButton>    
      </div>
        <div class="centerButton"></div>
        <br />
    
answered by 16.01.2018 в 21:23
0

The p: commandButton component does not have periodic events or triggers, so there is something in your code that affects its operation.

Verify that there is no component in your code that activates or updates your commandButton.

<p:commandButton 
   action="Ejecuccion" 
   icon="ui-icon-person" 
   value=" Ejecutar sentencia"  process="@this" 
   immediate="true">
 </p:commandButton>   

Notes:

  • action - > It implies a navigability in the code, I guess that's what what you want to do, otherwise you should have a actionLisener.
  • value - > It may be your problem, since this is where the label of the     button, and you have a sentence execution in text.
  • immediate - > To carry out the action without validating or having     account other parts of the form, pass any error. No     recommended.
  • process - > By default it is not necessary to add it, but if you want to be sure that the component's request is made, it is not necessary to add it.
  • Greetings.

    EDITING

    actionLisener or action - > These are the events that invoke the controller / bean to perform the predefined event. Verify that you do not do it in the value.

    EDITING

      

    To eliminate the default behavior of the event by pressing the   ENTER key uses a "dumb" button.

    Primefaces solution:

    <p:defaultCommand target="dummy"/>
    <p:commandButton id="dummy" process="@none" global="false" style="display:none;"/>
    

    p: defaultCommand - > Change the behavior you describe by default and redirect the ENTER action to the component you select.

        
    answered by 16.01.2018 в 20:54