Here is tml code of my issue:


     
    

        
            

            
                
                    ${message:selectTypeOfTicket}
                    

                    
            
            
            
                
                
                    
                        ${message:numberOfTickets}
                        
                               


                     

                
                
                    
                    ${message:datum}
                    
                



            


            
                
                    ${message:number}
                           
                
                
                    ${message:serial}
                        
                 
            
            
                
                    ${message:price}
                          
                
            
            
                


                


                
                    





                
            

            


                
                    Crear  Fracciones
                    Para el sorteo: 
                    Fecha:  
                    
                        
                    

                    
                
            

        


        
            
                
                    Generar
            
        

    



> From: wintertime0...@outlook.com
> To: users@tapestry.apache.org
> Subject: Can't call event on submit
> Date: Mon, 20 Oct 2014 14:08:44 +0100
> 
> Hello, I have yet again very odd situation here. When I try to press 
> Confirmar in dialog box it doesn't get fired, and the reason it I may suspect 
> is because dialog goes to the bottom of DOM, so my submit button is actually 
> not inside of the current form anymore. I tried to wrap it with yet another 
> form, but it wouldn't get fired, since all values are inside the current form.
> 
> For better understanding what I am talking about I am providing source code 
> that looks like this:
> /*
>  * To change this template, choose Tools | Templates
>  * and open the template in the editor.
>  */
> package rs.domaci.pages;
> 
> import org.apache.commons.lang.StringUtils;
> import org.apache.tapestry5.ComponentResources;
> import org.apache.tapestry5.EventConstants;
> import org.apache.tapestry5.PersistenceConstants;
> import org.apache.tapestry5.alerts.AlertManager;
> import org.apache.tapestry5.alerts.Duration;
> import org.apache.tapestry5.alerts.Severity;
> import org.apache.tapestry5.annotations.Component;
> import org.apache.tapestry5.annotations.InjectComponent;
> import org.apache.tapestry5.annotations.OnEvent;
> import org.apache.tapestry5.annotations.Persist;
> import org.apache.tapestry5.annotations.Property;
> import org.apache.tapestry5.corelib.components.Form;
> import org.apache.tapestry5.corelib.components.Zone;
> import org.apache.tapestry5.hibernate.annotations.CommitAfter;
> import org.apache.tapestry5.ioc.annotations.Inject;
> import org.apache.tapestry5.json.JSONObject;
> import org.apache.tapestry5.services.ComponentSource;
> import org.apache.tapestry5.services.Request;
> import org.apache.tapestry5.services.ajax.AjaxResponseRenderer;
> import org.hibernate.Session;
> import rs.domaci.entities.Tiket;
> import rs.domaci.entities.TiketStatus;
> import rs.domaci.entities.TipDrawTiketa;
> import rs.domaci.entities.TipOsoblja;
> import rs.domaci.services.ProtectedPage;
> 
> /**
>  * This page is for generating tickets!
>  *
>  * @author
>  */
> @ProtectedPage(getTipOsoblja = TipOsoblja.ADMIN)
> public class AddTickets {
> 
>     @Property
>     private String drawNumberOfTicket;
>     @Inject
>     private Session hibernate;
>     @Property
>     private int series;
>     @Property
>     @Persist(PersistenceConstants.CLIENT)
>     private String datum;
>     @Inject
>     private ComponentSource componentSource;
>     @Property
>     // price
>     private int cijena;
>     @Property
>     @Persist
>     private String kopijaDatum;
>     @Property
>     @Persist
>     private int kopijaBroj;
>     /**
>      * @Property private
>      */
>     @Property
>     @Persist(PersistenceConstants.CLIENT)
>     private int broj;
>     @Property
>     private int brojTiketa;
>     @Property
>     private TiketStatus status = TiketStatus.DISPONIBLE;
>     @InjectComponent
>     private Zone zonaDjelovanja;
>     @Inject
>     private Request request;
>     @Inject
>     private AjaxResponseRenderer ajaxResponseRenderer;
>     @Inject
>     private ComponentResources componentResources;
>     @Property
>     @Persist(PersistenceConstants.FLASH)
>     private TipDrawTiketa drawTip;
>     @Inject
>     private AlertManager manager;
>     @Component(id = "dodajTiket")
>     private Form form;
>     // Generally useful bits and pieces
>     void setupRender() {
> 
>         datum = null;
>         updateDisplay(drawTip);
>     }
> 
>     public String getFormatirajMe() {
>         String prviDio = String.format("%03d", series);
>         String drugiDio = String.format("%02d", broj);
>         return prviDio + drugiDio;
>     }
> 
>     public Object getOsvjeziZonu() {
>         if (drawTip == drawTip.LOT_NAC) {
>             brojTiketa = 20;
>             return zonaDjelovanja.getBody();
>         } else if (drawTip == drawTip.CHANCES) {
>             brojTiketa = 10;
>             return zonaDjelovanja.getBody();
>         } else if (drawTip == drawTip.NAVIDENA) {
>             brojTiketa = 10;
>             return zonaDjelovanja.getBody();
>         } else {
>             brojTiketa = 10;
>             return zonaDjelovanja.getBody();
>         }
>     }
>     
>     @OnEvent(value = EventConstants.VALUE_CHANGED, component = "drawTip")
>     public Object updateDisplay(TipDrawTiketa tipDrawTiketaa) {
>         drawTip = tipDrawTiketaa;
>         if (drawTip == TipDrawTiketa.LOT_NAC) {
>             brojTiketa = 20;
>             return zonaDjelovanja.getBody();
>         } else if (drawTip == TipDrawTiketa.CHANCES) {
>             brojTiketa = 10;
>             return zonaDjelovanja.getBody();
>         } else if (drawTip == TipDrawTiketa.NAVIDENA) {
>             brojTiketa = 20;
>             return zonaDjelovanja.getBody();
>         } else {
>             brojTiketa = 20;
>             return zonaDjelovanja.getBody();
>         }
>     }
> 
>     /**
>      *
>      * @return
>      */
>     
>      @OnEvent(value = "submit", component = "dodajTiket")
>     @CommitAfter
>     void onSuccess() {
>     
>         hibernate.save(new Tiket(StringUtils.leftPad(String.valueOf(series + 
> "" + broj), 5, ""), datum, drawTip, String.format("%03d", series), 
> String.format("%02d", broj), String.format("%02d", brojTiketa), status, 
> cijena));
>         String redom = "Created ticket sheet  serial   " + series + "\n" + "  
>   number   " + broj;
>         manager.alert(Duration.UNTIL_DISMISSED, Severity.INFO, redom);
>         componentResources.discardPersistentFieldChanges();
>     }
>     
>     @Property
>     private JSONObject params;
> 
>     @OnEvent(EventConstants.ACTIVATE)
>     public void onActivate() {
> 
>         kopijaBroj = brojTiketa;
>         params = new JSONObject();
> 
>         params.accumulate("modal", true);
>         params.accumulate("width", 330);
> 
> 
>     }
> }
> 
> 
> 
> My Q. is should I make event instead of submit and make onDodajTiket event 
> which will get fired once I click on a button Confirmar or is there any other 
> solution, easier one, to this?
> 
> 
>                                         
                                          

Reply via email to