/* (non-Javadoc)
* @see org.eclipse.jst.jsf.taglibprocessing.attributevalues.MethodBindingType#isValidValue(java.lang.String)
*/
public boolean isValidValue(String value){
if (value == null || (value != null && value.length() == 0)) {
IValidationMessage msg = new ValidationMessage(Messages.ActionType_invalid_empty_value);
getValidationMessages().add(msg);
return false;
}
//any other value should be one of the possible values
//optimize
IWorkspaceContextResolver wr = IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(getStructuredDocumentContext());
if (wr == null)
return true;//shouldn't get here
//in case that this is not JSF faceted or missing configs, need to pass
if (JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(wr.getProject()) == null)
return true;
IFile jsp = (IFile)wr.getResource();
List<NavigationRuleType> rules = JSFAppConfigManagerFactory.getJSFAppConfigManagerInstance(wr.getProject()).getNavigationRulesForPage(jsp);
for (final NavigationRuleType rule : rules) {
for (Iterator cases=rule.getNavigationCase().iterator();cases.hasNext();) {
NavigationCaseType navCase = (NavigationCaseType)cases.next();
if (navCase.getFromOutcome() != null && navCase.getFromOutcome().getTextContent() != null &&
value.equals(navCase.getFromOutcome().getTextContent().trim()))
return true;
}
}
if (JSFVersion.valueOfProject(jsp.getProject()).compareTo(JSFVersion.V2_0) >= 0) {
int index = value.indexOf('?');
if (index != -1) {
value = value.substring(0, index);
}
if (value != null && value.length() > 1) {
IVirtualFolder webRoot = ComponentCore.createComponent(jsp.getProject()).getRootFolder();
if (value.charAt(0) == '/') {
IVirtualFile file = webRoot.getFile(new Path(value));
if (file.exists()) {
return true;
}
} else {
IPath webContentPath = webRoot.getUnderlyingFolder().getFullPath();
IPath filePath = jsp.getFullPath();
if (filePath.matchingFirstSegments(webContentPath) == webContentPath.segmentCount()) {
String extension = filePath.getFileExtension();
filePath = filePath.removeFirstSegments(webContentPath.segmentCount());
filePath = filePath.removeLastSegments(1);
filePath = filePath.append(value);
if (filePath.getFileExtension() == null && extension != null) {
filePath = filePath.addFileExtension(extension);
}
IVirtualFile file = webRoot.getFile(filePath);
if (file.exists()) {
return true;
}
}
}
}
}
IValidationMessage msg = new ValidationMessage(Messages.ActionType_invalid_value);
getValidationMessages().add(msg);
return false;
}