use of jakarta.faces.view.facelets.FaceletException in project mojarra by eclipse-ee4j.
the class SAXCompiler method doCompile.
protected FaceletHandler doCompile(CompilationManager mngr, CompilationHandler handler, URL src, String alias) throws IOException {
String encoding = getEncoding();
try (InputStream is = new BufferedInputStream(src.openStream(), 1024)) {
writeXmlDecl(is, encoding, mngr);
SAXParser parser = createSAXParser(handler);
parser.parse(is, handler);
} catch (SAXException e) {
throw new FaceletException("Error Parsing " + alias + ": " + e.getMessage(), e.getCause());
} catch (ParserConfigurationException e) {
throw new FaceletException("Error Configuring Parser " + alias + ": " + e.getMessage(), e.getCause());
} catch (FaceletException e) {
throw e;
}
FaceletHandler result = new EncodingHandler(mngr.createFaceletHandler(), encoding, mngr.getCompilationMessageHolder());
mngr.setCompilationMessageHolder(null);
return result;
}
use of jakarta.faces.view.facelets.FaceletException in project myfaces by apache.
the class LoadBundleHandler method apply.
/**
* See taglib documentation.
*
* See jakarta.faces.view.facelets.FaceletHandler#apply(jakarta.faces.view.facelets.FaceletContext,
* jakarta.faces.component.UIComponent)
*/
@Override
public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, ELException {
UIViewRoot root = ComponentSupport.getViewRoot(ctx, parent);
ResourceBundle bundle = null;
try {
ResourceBundle.Control bundleControl = MyfacesConfig.getCurrentInstance().getResourceBundleControl();
String name = this.basename.getValue(ctx);
ClassLoader cl = ClassUtils.getContextClassLoader();
Locale locale = root != null && root.getLocale() != null ? root.getLocale() : Locale.getDefault();
if (bundleControl == null) {
bundle = ResourceBundle.getBundle(name, locale, cl);
} else {
bundle = ResourceBundle.getBundle(name, locale, cl, bundleControl);
}
} catch (Exception e) {
throw new TagAttributeException(this.tag, this.basename, e);
}
ResourceBundleMap map = new ResourceBundleMap(bundle);
FacesContext faces = ctx.getFacesContext();
faces.getExternalContext().getRequestMap().put(this.var.getValue(ctx), map);
}
use of jakarta.faces.view.facelets.FaceletException in project myfaces by apache.
the class SAXCompiler method doCompile.
@Override
public CompilerResult doCompile(URL src, String alias) throws IOException, FaceletException, ELException, FacesException {
CompilationManager mngr = null;
InputStream is = null;
String encoding = null;
try {
is = new BufferedInputStream(src.openStream(), 1024);
mngr = new CompilationManager(alias, this, getFaceletsProcessingInstructions(src, alias));
encoding = writeXmlDecl(is, mngr);
CompilationHandler handler = new CompilationHandler(mngr, alias);
SAXParser parser = this.createSAXParser(handler);
parser.parse(is, handler);
} catch (SAXException e) {
throw new FaceletException("Error Parsing " + alias + ": " + e.getMessage(), e.getCause());
} catch (ParserConfigurationException e) {
throw new FaceletException("Error Configuring Parser " + alias + ": " + e.getMessage(), e.getCause());
} finally {
if (is != null) {
is.close();
}
}
return new CompilerResult(new EncodingHandler(mngr.createFaceletHandler(), encoding), mngr.getDoctype());
}
use of jakarta.faces.view.facelets.FaceletException in project myfaces by apache.
the class SAXCompiler method doCompileCompositeComponentMetadata.
/**
* @since 2.0.1
*/
@Override
protected CompilerResult doCompileCompositeComponentMetadata(URL src, String alias) throws IOException, FaceletException, ELException, FacesException {
CompilationManager mngr = null;
InputStream is = null;
String encoding = null;
try {
is = new BufferedInputStream(src.openStream(), 1024);
mngr = new CompilationManager(alias, this, getFaceletsProcessingInstructions(src, alias));
encoding = getXmlDecl(is, mngr);
CompositeComponentMetadataHandler handler = new CompositeComponentMetadataHandler(mngr, alias);
SAXParser parser = this.createSAXParser(handler);
parser.parse(is, handler);
} catch (SAXException e) {
throw new FaceletException("Error Parsing " + alias + ": " + e.getMessage(), e.getCause());
} catch (ParserConfigurationException e) {
throw new FaceletException("Error Configuring Parser " + alias + ": " + e.getMessage(), e.getCause());
} finally {
if (is != null) {
is.close();
}
}
return new CompilerResult(new EncodingHandler(mngr.createFaceletHandler(), encoding), mngr.getDoctype());
}
use of jakarta.faces.view.facelets.FaceletException in project myfaces by apache.
the class SAXCompiler method doCompileViewMetadata.
/**
* @since 2.0
*/
@Override
protected CompilerResult doCompileViewMetadata(URL src, String alias) throws IOException, FaceletException, ELException, FacesException {
CompilationManager mngr = null;
InputStream is = null;
String encoding = null;
try {
is = new BufferedInputStream(src.openStream(), 1024);
mngr = new CompilationManager(alias, this, getFaceletsProcessingInstructions(src, alias));
encoding = getXmlDecl(is, mngr);
final ViewMetadataHandler handler = new ViewMetadataHandler(mngr, alias);
final SAXParser parser = this.createSAXParser(handler);
if (System.getSecurityManager() != null) {
try {
final InputStream finalInputStream = is;
AccessController.doPrivileged((PrivilegedExceptionAction) () -> {
parser.parse(finalInputStream, handler);
return null;
});
} catch (PrivilegedActionException pae) {
Exception e = pae.getException();
if (e instanceof SAXException) {
throw new FaceletException("Error Parsing " + alias + ": " + e.getMessage(), e.getCause());
} else if (e instanceof IOException) {
throw (IOException) e;
}
}
} else {
parser.parse(is, handler);
}
} catch (SAXException e) {
throw new FaceletException("Error Parsing " + alias + ": " + e.getMessage(), e.getCause());
} catch (ParserConfigurationException e) {
throw new FaceletException("Error Configuring Parser " + alias + ": " + e.getMessage(), e.getCause());
} finally {
if (is != null) {
is.close();
}
}
return new CompilerResult(new EncodingHandler(mngr.createFaceletHandler(), encoding), mngr.getDoctype());
}
Aggregations