Author: ivaynberg Date: Fri Feb 5 01:59:43 2010 New Revision: 906768 URL: http://svn.apache.org/viewvc?rev=906768&view=rev Log: WICKET-2717 bookmarkablepagelink broken on ajaxupdate Issue: WICKET-2717
Modified: wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.core.prefs wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.ui.prefs wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java Modified: wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.core.prefs URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.core.prefs?rev=906768&r1=906767&r2=906768&view=diff ============================================================================== --- wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.core.prefs (original) +++ wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.core.prefs Fri Feb 5 01:59:43 2010 @@ -1,4 +1,4 @@ -#Wed Aug 26 08:15:28 PDT 2009 +#Thu Feb 04 17:57:52 PST 2010 eclipse.preferences.version=1 org.eclipse.jdt.core.builder.cleanOutputFolder=clean org.eclipse.jdt.core.builder.duplicateResourceTask=warning @@ -96,15 +96,15 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=20 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=48 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=80 -org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=64 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=64 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 @@ -145,9 +145,9 @@ org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=100 +org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.compact_else_if=true -org.eclipse.jdt.core.formatter.continuation_indentation=1 +org.eclipse.jdt.core.formatter.continuation_indentation=2 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true @@ -162,6 +162,9 @@ org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true org.eclipse.jdt.core.formatter.indentation.size=4 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert @@ -330,19 +333,21 @@ org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false org.eclipse.jdt.core.formatter.lineSplit=100 -org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=true -org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=true +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=2 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true org.eclipse.jdt.core.formatter.tabulation.char=tab org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false -org.eclipse.jdt.core.formatter.wrap_before_binary_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore org.eclipse.jdt.core.incompleteClasspath=error Modified: wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.ui.prefs URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.ui.prefs?rev=906768&r1=906767&r2=906768&view=diff ============================================================================== --- wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.ui.prefs (original) +++ wicket/branches/wicket-1.4.x/wicket/.settings/org.eclipse.jdt.ui.prefs Fri Feb 5 01:59:43 2010 @@ -1,4 +1,4 @@ -#Wed Aug 01 11:37:07 CEST 2007 +#Thu Feb 04 17:57:52 PST 2010 comment_clear_blank_lines=false comment_format_comments=true comment_format_header=true @@ -11,7 +11,7 @@ comment_separate_root_tags=true eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_profile=_wicket +formatter_profile=_Wicket formatter_settings_version=11 instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * Gets ${bare_field_name}.\r\n * @return ${bare_field_name}\r\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * Sets ${bare_field_name}.\r\n * @param ${param} ${bare_field_name}\r\n */</template><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * Construct.\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment"/><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags} \r\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/*\r\n * Licensed to the Apache Software Foundation (ASF) under one or more\r\n * contributor license agreements. See the NOTICE file distributed with\r\n * this work for additional information regarding copyright ownership.\r\n * The ASF licenses this file to You under the Apache License, Version 2.0\r\n * (the "License"); you may not use this file except in compliance with\r\n * the License. You may obtain a copy of the License at\r\n *\r\n * http\://www.apache.org/licenses/LICENSE-2.0\r\ n *\r\n * Unless required by applicable law or agreed to in writing, software\r\n * distributed under the License is distributed on an "AS IS" BASIS,\r\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n * See the License for the specific language governing permissions and\r\n * limitations under the License.\r\n */\r\n${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">throw new RuntimeException(${exception_var});</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="c onstructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template></templates> Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java?rev=906768&r1=906767&r2=906768&view=diff ============================================================================== --- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java (original) +++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/RequestUtils.java Fri Feb 5 01:59:43 2010 @@ -34,12 +34,12 @@ public final class RequestUtils { /** - * Decode the provided queryString as a series of key/ value pairs and set them in the provided - * value map. + * Decode the provided queryString as a series of key/ value pairs and set + * them in the provided value map. * * @param queryString - * string to decode, uses '&' to separate parameters and '=' to separate key from - * value + * string to decode, uses '&' to separate parameters and '=' to + * separate key from value * @param params * parameters map to write the found key/ value pairs to */ @@ -52,7 +52,7 @@ if (bits.length == 2) { params.add(WicketURLDecoder.QUERY_INSTANCE.decode(bits[0]), - WicketURLDecoder.QUERY_INSTANCE.decode(bits[1])); + WicketURLDecoder.QUERY_INSTANCE.decode(bits[1])); } else { @@ -62,7 +62,8 @@ } /** - * decores url parameters form <code>queryString</code> into <code>parameters</code> map + * decores url parameters form <code>queryString</code> into + * <code>parameters</code> map * * @param queryString * @param parameters @@ -175,13 +176,17 @@ */ public final static String toAbsolutePath(final String relativePagePath) { - HttpServletRequest req = ((WebRequest)RequestCycle.get().getRequest()).getHttpServletRequest(); + HttpServletRequest req = ((WebRequest)RequestCycle.get().getRequest()) + .getHttpServletRequest(); return toAbsolutePath(req.getRequestURL().toString(), relativePagePath); } /** * Calculates absolute path to url relative to another absolute url. * + * NOTE: this method must be called within a thread processing a wicket + * request as it depends on {...@link RequestCycle} threadlocal + * * @param requestPath * absolute path. * @param relativePagePath @@ -210,17 +215,33 @@ { StringBuffer tempRelative = new StringBuffer(relativePagePath); - // Go up through hierarchy until we find most common directory for both pathes. + // Go up through hierarchy until we find most common directory for + // both pathes. while (tempRelative.indexOf("../") == 0) { // Delete ../ from relative path tempRelative.delete(0, 3); - // Delete last slash from result - result.setLength(result.length() - 1); + /* + * i cant believe this is the only way to do this, what a mess! + * i am so happy code like this and all its friends are + * unnecessary and gone in 1.5 see WICKET-2717 and WICKET-2312 + * the reason we have to do this is that the ajax request is + * done against the context path, while the url of the browser + * may contain mounts and is not changed by the ajax request, so + * we have to generate a link that is not relative to the + * current request but to whatever the browser has in its url + * bar + */ + if (RequestCycle.get() != null + && !((WebRequest)RequestCycle.get().getRequest()).isAjax()) + { + // Delete last slash from result + result.setLength(result.length() - 1); - // Delete everyting up to last slash - result.delete(result.lastIndexOf("/") + 1, result.length()); + // Delete everyting up to last slash + result.delete(result.lastIndexOf("/") + 1, result.length()); + } } result.append(tempRelative); } Modified: wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java URL: http://svn.apache.org/viewvc/wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java?rev=906768&r1=906767&r2=906768&view=diff ============================================================================== --- wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java (original) +++ wicket/branches/wicket-1.4.x/wicket/src/main/java/org/apache/wicket/protocol/http/request/WebRequestCodingStrategy.java Fri Feb 5 01:59:43 2010 @@ -254,16 +254,9 @@ boolean portletRequest = requestContext.isPortletRequest(); boolean sharedResourceURL = false; - boolean isAjax = ((WebRequestCycle)requestCycle).getWebRequest().isAjax(); - boolean skipRelativePathPrefix = false; - if (url != null && !portletRequest) { - // We've found the URL and it's mounted. - - // In the case of Ajax, we don't want to prepend a relative path - // to the mounted URL. See WICKET-2312. - skipRelativePathPrefix = isAjax; + // Do nothing - we've found the URL and it's mounted. } else if (requestTarget instanceof IBookmarkablePageRequestTarget) { @@ -307,7 +300,7 @@ else if (IRedirectListener.class.isAssignableFrom(rli.getMethod() .getDeclaringClass())) { - if (isAjax) + if (((WebRequestCycle)requestCycle).getWebRequest().isAjax()) { // TODO: Probably not all Ajax based redirects need to break out of // ResourceURL encoding @@ -361,8 +354,7 @@ if (url != null) { String result = null; - if (!UrlUtils.isRelative(url.toString()) || (!sharedResourceURL && portletRequest) || - skipRelativePathPrefix) + if (!UrlUtils.isRelative(url.toString()) || (!sharedResourceURL && portletRequest)) { result = url.toString(); }