Hmm, it did not work for me..
I tried the wicket version, but it still askes me if I want to navigate away
from the page when I hit enter in the TextField


richardwilko wrote:
> 
> Its an automatic thing that if your form has an input box and you press
> enter it will try to submit it normally.
> 
> I wrote a piece on how to stop this on my blog (but it also makes the
> normal ajax submit button fire, which you might not want).
> 
> 
> http://richard-wilkinson.co.uk/2008/04/05/how-to-stop-non-ajax-form-submits-in-wicket/
> http://richard-wilkinson.co.uk/2008/04/05/how-to-stop-non-ajax-form-submits-in-wicket/
>  
> 
> That uses prototype, but you may be able to adapt it to use other js
> libraries.
> 
> The general idea is, intercept the form submit event and stop it in
> javascript.
> 
> Richard
> 
> 
> 
> ulrik wrote:
>> 
>> Hello!
>> 
>> I have a problem. A have a ModalWindow with three components on it; a
>> TextField and two AjaxSubmitLinks.
>> The problem is that when I place the cursor on the TextField and press
>> the Enter key, something bad happens. There is a popup dialog that askes
>> me if "Are you sure you want to navigate to another page..."
>> 
>> What I would like to do is somehow disable the enter press in the
>> TextField, or make it so it doesn't generate an event that pops up that
>> dialog.
>> 
>> The HTML for the Modal window (WHich is a ModalWindow with a panel)
>> 
>> <head>
>>     <wicket:head>
>>         <style>
>>             #ta {
>>                 width:250px;
>>                 height:100px;
>>             }
>>             #outer_local{
>>                 text-align:left;
>>                 padding-left:10px;
>>             }
>>         </style>
>>     </wicket:head>
>> </head>
>> 
>> <wicket:panel>
>>     <form wicket:id="form">
>>         <div id="outer_local">
>>             <h1><wicket:message key="header"/></h1>
>>             <br>
>>             <wicket:message key="name"/> <input type="text"
>> wicket:id="draftName" />
>>             <br>
>>             <br>
>>             <div class="buttonpanel">
>>                 <ul>
>>                     <li> # <wicket:message key="saveDraft">[Spara och
>> stäng]</wicket:message> </li>
>>                     <li> # <wicket:message
>> key="cancel">[Avbryt]</wicket:message> </li>
>>                 </ul>
>>             </div>
>>         </div>
>>     </form>
>> </wicket:panel>
>> 
>> 
>> The corresponding java file is:
>> 
>> public class SaveDraftDialog extends Panel {
>>     private TextField m_draftName;
>>     private WebInvoiceModel m_invoiceModel;
>>     private ModalWindow m_window;
>>     private InvoiceButtons m_buttonPanel;
>>     private Form m_form;
>> 
>>     public SaveDraftDialog(String s, InvoiceButtons buttonPanel) {
>>         super(s);
>> 
>>         m_buttonPanel = buttonPanel;
>>         m_window = buttonPanel.getSaveDraftModalWindow();
>>         m_invoiceModel = ((PageroOnlineWebSession)
>> Session.get()).getInvoiceModel();
>> 
>>         m_form = new Form("form");
>>         add(m_form);
>> 
>>         String oldDraftName = "";
>>         if(m_invoiceModel.isReOpen()){
>>             oldDraftName = m_invoiceModel.getDraftName();
>>         }
>>         m_draftName = new TextField("draftName",new Model(oldDraftName));
>>         m_form.add(m_draftName);
>> 
>>         m_form.add(new AjaxSubmitLink("saveButton",m_form){
>>             protected void onSubmit(AjaxRequestTarget ajaxRequestTarget,
>> Form form) {
>>                 String input = m_draftName.getModelObjectAsString();
>>                 m_buttonPanel.saveDraft(input);
>>                 m_window.close(ajaxRequestTarget);
>>                
>> ajaxRequestTarget.addComponent(m_buttonPanel.getFeedbackPanel());
>>             }
>>         });
>> 
>>         m_form.add(new AjaxSubmitLink("cancelButton",m_form){
>>             protected void onSubmit(AjaxRequestTarget ajaxRequestTarget,
>> Form form) {
>>                 m_window.close(ajaxRequestTarget);
>>             }
>>         });
>>     }
>> }
>> 
>> And here is how I open the ModalWindow:
>> 
>> m_saveDraftModalWindow = new ModalWindow("saveDraft");
>> add(m_saveDraftModalWindow);
>> 
>> m_saveDraftModalWindow.setContent(new
>> SaveDraftDialog(m_saveDraftModalWindow.getContentId(),this));
>> m_saveDraftModalWindow.setTitle(BundleSupport.getMessageWicketTest("draft.saveDraft",WebSession.get().getLocale()));
>>         m_saveDraftModalWindow.setCookieName("save-modal");
>>        
>> m_saveDraftModalWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
>>         
>>         m_saveDraftModalWindow.setCloseButtonCallback(new
>> ModalWindow.CloseButtonCallback()
>>         {
>>             public boolean onCloseButtonClicked(AjaxRequestTarget target)
>>             {
>>                 return true;
>>             }
>>         });
>> 
>> Would be great if anyone could help me here
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/TextField-inside-a-ModalWindow-problems-tp20363183p20375853.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to