Author: scabanovich
Date: 2011-11-15 19:20:01 -0500 (Tue, 15 Nov 2011)
New Revision: 36358
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PostfixUrlPattern.java
Log:
JBIDE-10177
https://issues.jboss.org/browse/JBIDE-10177
Fix for verification of error page with .xhtml extension, when default suffix is not
specified.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2011-11-16
00:17:49 UTC (rev 36357)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2011-11-16
00:20:01 UTC (rev 36358)
@@ -160,8 +160,13 @@
} else if(JSF_CONVERT_URL_TO_PATH.equals(id)) {
if(!EclipseResourceUtil.hasNature(model, JSFNature.NATURE_ID)) return EMPTY_LIST;
ArrayList<Object> list = new ArrayList<Object>();
- String path = JSFWebProject.getInstance(model).getUrlPattern().getJSFPath(prefix);
- if(path != null && path.length() > 0) list.add(path);
+ List<String> paths =
JSFWebProject.getInstance(model).getUrlPattern().getJSFPaths(prefix);
+ if(!paths.isEmpty()) {
+ list.addAll(paths);
+ } else {
+ String path = JSFWebProject.getInstance(model).getUrlPattern().getJSFPath(prefix);
+ if(path != null && path.length() > 0) list.add(path);
+ }
return list;
} else if(JSF_GET_TAGLIBS.equals(id)) {
ArrayList<Object> list = new ArrayList<Object>();
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java 2011-11-16
00:17:49 UTC (rev 36357)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java 2011-11-16
00:20:01 UTC (rev 36358)
@@ -18,7 +18,7 @@
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
public class PatternLoader {
- static String DEFAULT_FILE_SUFFIX = ".jsp";
+ public static final String[] DEFAULT_SUFFIXES = {".jsp", ".xhtml",
".jspx"};
public static JSFUrlPattern DEFAULT_PATTERN = new PostfixUrlPattern();
static JSFUrlPattern[] DEFAULT_PATTERNS = new JSFUrlPattern[]{DEFAULT_PATTERN};
CompoundPattern pattern = new CompoundPattern();
@@ -37,7 +37,7 @@
pattern.setPatterns(DEFAULT_PATTERNS);
return;
}
- String fileSuffix = getFileSuffix(webxml);
+ String[] fileSuffixes = getFileSuffix(webxml);
ArrayList<JSFUrlPattern> list = new ArrayList<JSFUrlPattern>();
String servletName = getFacesServletName(webxml);
for (int i = 0; i < mappings.length; i++) {
@@ -46,18 +46,18 @@
String pattern = mappings[i].getAttributeValue("url-pattern");
JSFUrlPattern up = load(pattern);
if(up instanceof PostfixUrlPattern) {
- ((PostfixUrlPattern)up).setFileSuffix(fileSuffix);
+ ((PostfixUrlPattern)up).setFileSuffixes(fileSuffixes);
}
if(up != null) {
list.add(up);
}
}
- if(list.size() == 0 && fileSuffix.equals(DEFAULT_FILE_SUFFIX)) {
+ if(list.size() == 0 && fileSuffixes == DEFAULT_SUFFIXES) {
pattern.setPatterns(DEFAULT_PATTERNS);
} else if(list.size() == 0) {
JSFUrlPattern[] ps = new JSFUrlPattern[1];
ps[0] = new PostfixUrlPattern();
- ((PostfixUrlPattern)ps[0]).setFileSuffix(fileSuffix);
+ ((PostfixUrlPattern)ps[0]).setFileSuffixes(fileSuffixes);
pattern.setPatterns(ps);
} else {
pattern.setPatterns((JSFUrlPattern[])list.toArray(new JSFUrlPattern[0]));
@@ -70,9 +70,9 @@
return (s != null) ? s.getAttributeValue("servlet-name") :
"FacesServlet";
}
- String getFileSuffix(XModelObject webxml) {
+ String[] getFileSuffix(XModelObject webxml) {
String[] list = WebAppHelper.getWebAppContextParamValueList(webxml,
"javax.faces.DEFAULT_SUFFIX");
- return list == null || list.length == 0 || !list[0].startsWith(".") ?
DEFAULT_FILE_SUFFIX : list[0];
+ return list == null || list.length == 0 || !list[0].startsWith(".") ?
DEFAULT_SUFFIXES : list;
}
JSFUrlPattern load(String p) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PostfixUrlPattern.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PostfixUrlPattern.java 2011-11-16
00:17:49 UTC (rev 36357)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PostfixUrlPattern.java 2011-11-16
00:20:01 UTC (rev 36358)
@@ -15,24 +15,19 @@
public class PostfixUrlPattern implements JSFUrlPattern {
protected String postfix = ".jsf";
- protected String fileSuffix = ".jsp";
/*
* Fixes
https://jira.jboss.org/jira/browse/JBIDE-5577
* Fixes
https://jira.jboss.org/jira/browse/JBIDE-5635
* JSF files could be mapped to xhtml or jspx files also.
* All of this extensions should be checked.
*/
- protected String[] fileExtensions = {".jsp", ".xhtml",
".jspx"};
+ protected String[] fileExtensions = PatternLoader.DEFAULT_SUFFIXES;
public void setPostfix(String postfix) {
this.postfix = postfix;
}
- public void setFileSuffix(String s) {
- fileSuffix = s;
- }
-
- public void setFileExtentions(String[] fileExtentions) {
+ public void setFileSuffixes(String[] fileExtentions) {
this.fileExtensions = fileExtentions;
}
@@ -41,12 +36,21 @@
}
public boolean isJSFUrl(String path) {
- return (path.endsWith(postfix) || path.endsWith(fileSuffix));
+ if(path.endsWith(postfix)) {
+ return true;
+ }
+ for (String fileSuffix: fileExtensions) {
+ if(path.endsWith(fileSuffix)) {
+ return true;
+ }
+ }
+ return false;
}
public String getJSFPath(String url) {
if(url == null || url.length() == 0) return url;
- return (url.endsWith(postfix)) ? url.substring(0, url.length() - postfix.length()) +
fileSuffix : url;
+ List<String> ps = getJSFPaths(url);
+ return (ps.isEmpty()) ? url : ps.get(0);
}
public List<String> getJSFPaths(String url) {