You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by shimin_q <sm...@hotmail.com> on 2012/11/21 16:18:17 UTC

AJAX not working after migrating from wicket 1.5.5 to 6.3.0

I have a wicket application that implements a Form with multiple fields. 
AJAX form updating behavior onChange() is implemented so that a value change
in one field will trigger reset of some other fields.  All have been tested
working fine in wicket 1.5.5.  Now I just migrated to 6.3.0, none of this
AJAX behavior is working! :-(   Here is the code snippet that worked for
1.5.5.  Could anyone please tell me what I need to change to get the AJAX
behavior to work with wicket 6.3.0?  Thanks a lot!

public class MetaProfileForm extends Form<MetaProfile> {
          ...
		DropDownChoice<MetaProfileType> profileTypeBox = new
DropDownChoice<MetaProfileType>("type",
				new PropertyModel<MetaProfileType>(profile, "type"),
				Arrays.asList(MetaProfileType.values()),
				new IChoiceRenderer<MetaProfileType>() {
					private static final long serialVersionUID = 1L;
					@Override
					public Object getDisplayValue(MetaProfileType object) {
						return object.name();
					}
					@Override
					public String getIdValue(MetaProfileType object, int index) {
						return object.name();
					}
				}
		);
		profileTypeBox.setOutputMarkupId(true);
		add(profileTypeBox);
 
		profileTypeBox.add(new AjaxFormComponentUpdatingBehavior("onChange") {
			private static final long serialVersionUID = 1L;
			protected void onUpdate(AjaxRequestTarget target) {
				resetFieldsPerProfileType(target);
				//add any component that will be called in resetFieldsPerProfileType()
				target.add(oxeNodeBox);
				target.add(freeNumRangeBox);
				target.add(oxeProfileBox);
	...
	
			};
		});	

In resetFieldsPerProfileType(),

	protected void resetFieldsPerProfileType(AjaxRequestTarget target) {
		MetaProfileType selectedProfileType = profileTypeBox.getModelObject();
		if (selectedProfileType.equals(MetaProfileType.OXE))
		{
			oxeNodeAsteriskImg.add(new AttributeModifier("style", "display:"));
			oxeNodeLabel.add(new AttributeModifier("class", "requiredLabel"));
			oxeNodeBox.setChoices(getOXENodeList());
...
                  } else if (selectedProfileType.equals(MetaProfileType.OT))
{
                       //reset and reload some other fields
                       ...
                  }
         }

The corresponding HTML snippet:

	
 
              	 <label for="profileType" wicket:id="profileTypeLabel"
class="requiredLabel">Metaprofile 
                Type</label>
              	 <select id="profileType" name="profileType"
wicket:id="type">
                  <option>default</option>
                </select> 
        
 
	
            
 
              	 <label for="oxeNode" wicket:id="oxeNodeLabel"
class="requiredLabel">OXE Node</label>
              	<select id="oxeNode" name="oxeNode" wicket:id="oxeNode">
                  <option selected>OXENode</option>
                </select>
            
		 



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by shimin_q <sm...@hotmail.com>.
Just to add a bit more info.  The newmetaprofile link on the "8770main" page
looks like the following:

            
 <li> Create <./newmetaprofile>  </li>
           

Any suggestions/ideas for me to try would be appreciated!



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065p4654235.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by shimin_q <sm...@hotmail.com>.
After a lot of tries, here is what I obeserved so far in my envionment. 
Basically, it appears how the page with AJAX is loaded affects whether AJAX
listeners are enabled on the page.  Could anyone please take a look at below
and let me know why this is the case and what I need to do to fix it? 
Thanks a lot!!

I turned on the web console in my Firefox browser and watched the logging
messages.   

The page with AJAX is "http://127.0.0.1:7999/newmetaprofile".  The page that
contains a link to the "newmetaprofile" page is
"http://127.0.0.1:7999/8770main".  When the "newmetaprofile" page is loaded
by clicking on the newmetaprofile link on the "8770main" page, AJAX does not
work.  Here is the log (after the transition from the "8770main" page to the
"newmetaprofile" page, nothing happens)

[13:16:44.637] GET http://127.0.0.1:7999/8770main [HTTP/1.1 200 OK 342ms]
[13:16:54.010] GET http://127.0.0.1:7999/newmetaprofile [HTTP/1.1 302 Found
2766ms]
[13:16:56.886] GET http://127.0.0.1:7999/newmetaprofile?13 [HTTP/1.1 200 OK
37ms]

But if I type "http://127.0.0.1:7999/newmetaprofile" in the address bar to
load the page manually or if I refresh/reload the
"http://127.0.0.1:7999/newmetaprofile" page, a whole bunch of things happen
including the ajax scripts being called:

--
[13:18:54.754] GET http://127.0.0.1:7999/newmetaprofile [HTTP/1.1 302 Found
2761ms]
[13:18:57.494] GET http://127.0.0.1:7999/newmetaprofile?14 [HTTP/1.1 200 OK
79ms]
[13:18:57.621] GET
http://127.0.0.1:7999/wicket/resource/org.apache.wicket.resource.JQueryResourceReference/jquery/jquery-ver-1353527137996.js
[HTTP/1.1 304 Not Modified 300ms]
[13:18:57.622] GET
http://127.0.0.1:7999/wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-event-jquery-ver-1353527137996.js
[HTTP/1.1 304 Not Modified 276ms]
[13:18:57.622] GET
http://127.0.0.1:7999/wicket/resource/org.apache.wicket.ajax.AbstractDefaultAjaxBehavior/res/js/wicket-ajax-jquery-ver-1353527137996.js
[HTTP/1.1 304 Not Modified 290ms]
[13:18:57.623] GET
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css [HTTP/1.1
304 Not Modified 165ms]
[13:18:57.623] GET http://code.jquery.com/jquery-1.8.3.min.js [HTTP/1.1 304
Not Modified 186ms]
[13:18:57.624] GET
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js [HTTP/1.1 304
Not Modified 154ms]
...

Subsequently, AJAX behaves as expected, it resets fields when a metaprofile
type is selected.  I diff'd the newmetaprofile page source for the above two
scenarios.  Everything is the same, EXCEPT one difference in the generated
baseUrl:

Wicket.Ajax.baseUrl="newmetaprofile";  vs.
Wicket.Ajax.baseUrl="newmetaprofile?13";

For your reference, the entire header is attached below:::


<html xmlns:wicket="http://wicket.apache.org/">
<head>




<title wicket:id="pageTitle">Create Metaprofile</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,
maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet"
href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />  
      
            


</head>
<body>
<div id="container">
    <div id="header">
        
Create Metaprofile

    </div>
<form id="createMPForm" wicket:id="createMPForm" method="post"
action="./newmetaprofile?11-1.IFormSubmitListener-createMPForm"><div
style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden"><input
type="hidden" name="createMPForm_hf_0" id="createMPForm_hf_0" /></div>
<div id="content">
<div id="metaprofile">
        

          
	     
 
              	 <images/asterisk.gif> <label for="profileType"
wicket:id="profileTypeLabel" class="requiredLabel">Metaprofile Type</label>
              	 <select id="profileType" name="type" wicket:id="type">
<option selected="selected" value="">Choose One</option>
<option value="OXE">OXE</option>
<option value="OXE_WITH_OT">OXE_WITH_OT</option>
<option value="OXE_WITH_ICS">OXE_WITH_ICS</option>
<option value="OT">OT</option>
</select> 
            
...




--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065p4654234.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by shimin_q <sm...@hotmail.com>.
I have in the HTML head:

    <meta name="viewport" content="width=device-width, initial-scale=1,
maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet"
href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />  
      
            

I need the jquery-mobile stuff, so should I just comment out the   ?





--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065p4654076.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by Martijn Dashorst <ma...@gmail.com>.
Remove all your own jquery includes. Wicket 6 provides the latest and
greatest out of the box.

Martijn

On Wed, Nov 21, 2012 at 6:06 PM, shimin_q <sm...@hotmail.com> wrote:
> Well, maybe the problem is not in this part of wicket code.  As I mentioned,
> everything worked fine for me with wicket 1.5.5.  And the problem occurred
> right after I switched the wicket library from 1.5.5 to 6.3.0.  Perhaps I
> need to tweak my environment or configuration or set up somewhere, or
> anywhere else should I look to find the root cause for my problem?  Any
> suggestions would be appreciated.  Thanks.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065p4654073.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by shimin_q <sm...@hotmail.com>.
Well, maybe the problem is not in this part of wicket code.  As I mentioned,
everything worked fine for me with wicket 1.5.5.  And the problem occurred
right after I switched the wicket library from 1.5.5 to 6.3.0.  Perhaps I
need to tweak my environment or configuration or set up somewhere, or
anywhere else should I look to find the root cause for my problem?  Any
suggestions would be appreciated.  Thanks.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065p4654073.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by Francois Meillet <fr...@gmail.com>.
Works perfectly for me (6.3)



import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;


public class TestPage extends WebPage {

    private static final Logger log =
LoggerFactory.getLogger(TestPage.class);

    public TestPage() {

        add(new MetaProfileForm("form", new
CompoundPropertyModel<MetaProfile>(new MetaProfile())));
    }

    public class MetaProfileForm extends Form<MetaProfile> {

        public MetaProfileForm(String id, IModel<MetaProfile> profile) {
            super(id, profile);

            DropDownChoice<MetaProfileType> profileTypeBox = new
DropDownChoice<MetaProfileType>("type",
                    new PropertyModel<MetaProfileType>(profile, "type"),
                    Arrays.asList(MetaProfileType.values()),
                    new IChoiceRenderer<MetaProfileType>() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public Object getDisplayValue(MetaProfileType
object) {
                            return object.name();
                        }

                        @Override
                        public String getIdValue(MetaProfileType object, int
index) {
                            return object.name();
                        }
                    }
            );
            profileTypeBox.setOutputMarkupId(true);
            this.add(profileTypeBox);

            profileTypeBox.add(new
AjaxFormComponentUpdatingBehavior("onChange") {
                private static final long serialVersionUID = 1L;

                protected void onUpdate(AjaxRequestTarget target) {
                    resetFieldsPerProfileType(target);
                    System.out.println("onUpdate");
                }
            });
        }

        private void resetFieldsPerProfileType(AjaxRequestTarget target) {
            System.out.println("resetFieldsPerProfileType");
        }
    }

}




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd"
      xml:lang="fr" lang="fr">

<head></head>

<body>

<form wicket:id="form">
    <select wicket:id="type">
        <option>default</option>
    </select>

</form>

</body>

</html>


François




-----
François Meillet
Développeur Wicket - indépendant - Paris - IDF
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065p4654071.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by shimin_q <sm...@hotmail.com>.
Yes, it appears the onUpdate() was never called with wicket 6.3.0 when I
update the value in the DropDownChoice.  I am not sure what I need to do to
get it working with wicket 6, it was working fine in 1.5.5.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065p4654070.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AJAX not working after migrating from wicket 1.5.5 to 6.3.0

Posted by Andrea Del Bene <a....@abanet.it>.
What exactly is the problem with the new version of Wicket? Is the 
behavior not executed at all?
> I have a wicket application that implements a Form with multiple fields.
> AJAX form updating behavior onChange() is implemented so that a value change
> in one field will trigger reset of some other fields.  All have been tested
> working fine in wicket 1.5.5.  Now I just migrated to 6.3.0, none of this
> AJAX behavior is working! :-(   Here is the code snippet that worked for
> 1.5.5.  Could anyone please tell me what I need to change to get the AJAX
> behavior to work with wicket 6.3.0?  Thanks a lot!
>
> public class MetaProfileForm extends Form<MetaProfile> {
>            ...
> 		DropDownChoice<MetaProfileType> profileTypeBox = new
> DropDownChoice<MetaProfileType>("type",
> 				new PropertyModel<MetaProfileType>(profile, "type"),
> 				Arrays.asList(MetaProfileType.values()),
> 				new IChoiceRenderer<MetaProfileType>() {
> 					private static final long serialVersionUID = 1L;
> 					@Override
> 					public Object getDisplayValue(MetaProfileType object) {
> 						return object.name();
> 					}
> 					@Override
> 					public String getIdValue(MetaProfileType object, int index) {
> 						return object.name();
> 					}
> 				}
> 		);
> 		profileTypeBox.setOutputMarkupId(true);
> 		add(profileTypeBox);
>   
> 		profileTypeBox.add(new AjaxFormComponentUpdatingBehavior("onChange") {
> 			private static final long serialVersionUID = 1L;
> 			protected void onUpdate(AjaxRequestTarget target) {
> 				resetFieldsPerProfileType(target);
> 				//add any component that will be called in resetFieldsPerProfileType()
> 				target.add(oxeNodeBox);
> 				target.add(freeNumRangeBox);
> 				target.add(oxeProfileBox);
> 	...
> 	
> 			};
> 		});	
>
> In resetFieldsPerProfileType(),
>
> 	protected void resetFieldsPerProfileType(AjaxRequestTarget target) {
> 		MetaProfileType selectedProfileType = profileTypeBox.getModelObject();
> 		if (selectedProfileType.equals(MetaProfileType.OXE))
> 		{
> 			oxeNodeAsteriskImg.add(new AttributeModifier("style", "display:"));
> 			oxeNodeLabel.add(new AttributeModifier("class", "requiredLabel"));
> 			oxeNodeBox.setChoices(getOXENodeList());
> ...
>                    } else if (selectedProfileType.equals(MetaProfileType.OT))
> {
>                         //reset and reload some other fields
>                         ...
>                    }
>           }
>
> The corresponding HTML snippet:
>
> 	
>   
>                	 <label for="profileType" wicket:id="profileTypeLabel"
> class="requiredLabel">Metaprofile
>                  Type</label>
>                	 <select id="profileType" name="profileType"
> wicket:id="type">
>                    <option>default</option>
>                  </select>
>          
>   
> 	
>              
>   
>                	 <label for="oxeNode" wicket:id="oxeNodeLabel"
> class="requiredLabel">OXE Node</label>
>                	<select id="oxeNode" name="oxeNode" wicket:id="oxeNode">
>                    <option selected>OXENode</option>
>                  </select>
>              
> 		
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/AJAX-not-working-after-migrating-from-wicket-1-5-5-to-6-3-0-tp4654065.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org