0
votes

Hello I'm trying to create an AMP page on my site in JSF but I got this problem

The mandatory attribute '⚡' is missing in tag 'html ⚡ for top-level html

In JSF I got something like this

<!DOCTYPE html>
<html xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:o="http://omnifaces.org/ui"
    xmlns:of="http://omnifaces.org/functions"
    xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    >

There is no way that I can put this character "⚡" on my html page without having errors

Caused by: javax.faces.view.facelets.FaceletException: Error Parsing /faces/public/pages/event/event-detail-amp.xhtml: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.
    at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:456) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.compiler.SAXCompiler.doMetadataCompile(SAXCompiler.java:439) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.compiler.Compiler.metadataCompile(Compiler.java:130) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.createMetadataFacelet(DefaultFaceletFactory.java:503) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$200(DefaultFaceletFactory.java:106) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:205) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:203) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:97) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:92) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_80]
    at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:146) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:63) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:316) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:246) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:138) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:241) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:121) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198) [jsf-impl-2.2.8-jbossorg-1.jar:]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646) [jboss-jsf-api_2.2_spec-2.2.8.jar:2.2.8]
    ... 45 more

What can I do ?

1
Just add amp to your html tag, like <html amp xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:o="http://omnifaces.org/ui" xmlns:of="http://omnifaces.org/functions" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" xmlns:ui="http://xmlns.jcp.org/jsf/facelets" >Hackerman
That actually works, but I have to change it a bit.Víctor Cardozo
Glad to help @VictorHackerman

1 Answers

0
votes

@Hackerman solution works to me but I have to change it a bit

<html amp 
      xmlns:c="http://java.sun.com/jsp/jstl/core" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:o="http://omnifaces.org/ui" 
      xmlns:of="http://omnifaces.org/functions" 
      xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" 
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets" >

That produce this error

08:20:22,576 ERROR [io.undertow.request] (default task-9) UT005023: Exception handling request to /contiego-app/faces/public/pages/event/event-detail-amp.xhtml: javax.servlet.ServletException: Error Parsing /faces/public/pages/event/event-detail-amp.xhtml: Error Traced[line: 4] Attribute name "amp" associated with an element type "html" must be followed by the ' = ' character.

So I change it to this

<html amp="amp"
  xmlns:c="http://java.sun.com/jsp/jstl/core" 
  xmlns:f="http://java.sun.com/jsf/core" 
  xmlns:h="http://java.sun.com/jsf/html" 
  xmlns:o="http://omnifaces.org/ui" 
  xmlns:of="http://omnifaces.org/functions" 
  xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" 
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets" >

It seems to work for me :)