OmniFaces importConstants not available on ui:param - facelets

I have a web application currently deployed on Wildfly 26.1.0, using JSF 2.3 and OpenJDK 11. I'm also using the latest version of OmniFaces (3.13.3).
I'm trying to pass via ui:param a constant field value, and I'm experiencing a strange behaviour.
When I declare o:importConstants on the layout, or even on the composition, the value is never available on ui:param. However, if I change it to f:importConstants (inside f:metadata) everything works as I expected.
Layout
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:o="http://omnifaces.org/ui">
<o:importConstants type="com.mytest.AvailableOutcomes" />
<h:head>
<meta charset="utf-8" />
</h:head>
<h:body>
Layout outcome 1: #{outcome}
<ui:insert name="content" />
Layout outcome 2: #{outcome}
</h:body>
</html>
Composition
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:o="http://omnifaces.org/ui"
template="/faces/tst/importConstantsTestLayout.xhtml">
<o:importConstants type="com.mytest.AvailableOutcomes" />
<ui:param name="outcome" value="#{AvailableOutcomes.INDEX}" />
<ui:define name="content">
My outcome is #{outcome}
</ui:define>
</ui:composition>
Ouput
Layout outcome 1: <empty>
My outcome is <empty>
Layout outcome 2: <empty>
Working version
Layout
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:o="http://omnifaces.org/ui">
<h:head>
<meta charset="utf-8" />
</h:head>
<h:body>
<ui:insert name="content" />
</h:body>
</html>
Composition
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:o="http://omnifaces.org/ui"
template="/faces/tst/importConstantsTestLayout.xhtml">
<f:metadata>
<f:importConstants type="com.mytest.AvailableOutcomes" />
</f:metadata>
<ui:param name="outcome" value="#{AvailableOutcomes.INDEX}" />
<ui:define name="content">
My outcome is #{outcome}
</ui:define>
</ui:composition>
Output
My outcome is index
I would prefer using omnifaces importConstants so I can declared only once and use across all pages.
I'm not sure if this is the expected behaviour, or a bug.
If someone could shed a light, I would appreciate.
Thanks in advance for your help!

Related

Any idea why my Github Pages site isn't showing? ReactJS

here's the link to my GH page
https://filipdimko11.github.io/crypto-tracker/
When running it locally, the project renders everything. After hosting it on GH pages, though, the website doesn't render anything (no errors in the console either).
I tried making an empty commit, saw it as another solution on StackOverflow, but that didn't fix it. Using ReactJS, thanks.
The problem is because in your index.html file you are referencing your assets like /static/js/main.2227a53b.js which makes sense when you are running locally.
But when you deploy to github pages, the directory structure is different. To make it work properly you'd need the routes to be prefixed with crypto-tracker/ For example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
rel="stylesheet"
/>
<meta name="description" content="Your best crypto tracker!" />
<link rel="manifest" href="/manifest.json" />
<title>Crypto Tracker</title>
<script defer="defer" src="crypto-tracker/static/js/main.2227a53b.js"></script>
<link href="crypto-tracker/static/css/main.f53fb378.css" rel="stylesheet" />
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
Depending on what build tool you are using, this is probably configurable.

Why when i share to twitter i cant see any image to card? here are the meta tags i have

Here is the meta tags i have in my react app but still in twitter share i cant see any image. i use react-share library.
<meta property="og:url" content="https://test.com" />
<meta property="og:type" content="article" />
<meta property="og:description"content="Coding tales" />
<meta property="og:image" content="%PUBLIC_URL%/Test.png" />
<meta name="twitter:title" content="Test Blog">
<meta name="twitter:description" content="Coding tales">
<meta name="twitter:image" content="%PUBLIC_URL%/Test.png">
<meta name="twitter:card" content="summary">
<title>Test Blog</title>
In the validator of twitter i get :
INFO: Page fetched successfully
INFO: 12 metatags were found
INFO: twitter:card = summary tag found
INFO: Card loaded successfully
You need an absolute path for og:image or twitter:image - like https://....
Relative paths aren't supported by Twitter... I don't think is documented but this is how it works in fact.

Twitter Cards - "WARN: No metatags found"

Having setup metatags for sharable pages via a heroku-hosted react web app. I've noticed that Twitter cards are not being properly presented, despite page source correctly presenting twitter and og meta data.
Given the below - Is there anything I haven't considered yet?
Javascript:
I have tested with javascript disabled, and the site still renders correctly, with correct meta tags
Image Size:
Is within defined limits - 434px X 650px, 94KB
Hosting:
Hosted on Herokuapp, the URL is still using the herokuapp domain (hasn't been switched to a production url)
expressFullURL : https://project.herokuapp.com/share/[ID]
Image Hosting:
Images are referencing AWS S3 buckets in the url https://media.project.aws/[etc]
Robots:
The site does not have a robots.txt file
Below, is the head meta content:
twitter.image URL is dynamically loaded in
twitter.url, which is also dynamic using express to generate the full URL (http://project.com/share/page/1234)
<!-- basic meta -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<meta content="text/html; charset=UTF-8" name="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- content meta -->
<meta name="description" content="description content" />
<meta name="copyright" content="Copyright 2019" />
<!-- Twitter meta -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:site" content="#handle">
<meta property="twitter:image" content="${image.url}">
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="${expressFullURL}">
<meta property="twitter:title" content="Title">
<meta property="twitter:description" content="description content">
<!-- opengraph data -->
<meta property="og:title" content="Title" />
<meta property="og:description" content="description content" />
<meta property="og:url" content="${expressFullURL}" />
<meta property="og:image" content="${image.url}" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Site Name" />
Using https://cards-dev.twitter.com/validator
the response is:
INFO: Page fetched successfully
WARN: No metatags found
Meta is correct on page, so can't understand why no metatags can be found
I had a similar situation, but seem to have it working. I kept an eye on the Heroku logs heroku logs --tail while clicking the validator preview button. Turns out I was getting a 500 error from my app, because of the format of the request from the validator. Might be worth a check.
I made a couple of observations that I'd like to document as an answer here:
A <meta charset="utf-8"> tag is required.
The twitter:image tag needs a full HTTPS URL, like https://host.com/some/image.jpg.
The twitter card validator needs to be refreshed for each change. It is not enough to just click on the "Preview Card" button again, you need to reload the webpage (CMD-R on the Mac) and enter the card URL in the text field. Otherwise the validator doesn't seem to load the latest changes.
The error message"INFO: Page fetched successfullyWARN: No metatags found"is
completely misleading. It is shown even if the URL doesn't exist.
A minimum working example is:
<html>
<head>
<meta charset="utf-8">
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:site" content="#username"/>
<meta name="twitter:title" content="A title"/>
<meta name="twitter:description" content="A description."/>
<meta name="twitter:image" content="https://host.com/some/image.jpg"/>
</head>
<body>
</body>
</html>

Loading another Page in Content Page is not Working in ASP.NET with EXT.NET V2.2

I have EXACTLY the same Problem as this one:
old Topic
Just I use Ext.Net V2.2 and there is no Mode="iFrame", only Mode="Frame" wich doesnt work...
Ext.Net components just dont work on loaded Page.
This is the Panel i try to load other content to:
<ext:Panel ID="p_Center" runat="server" BodyPadding="5" Region="Center" Margins="5 5 5 0" Frame="true" >
<Loader runat="server" AutoLoad="true" Url="./X_000_Sites/anotherPage.aspx" Mode="Frame" Scripts="true" ></Loader>
</ext:Panel>
also tried without the Frame="true"... Normal Html-Stuff works but not Ext.Net components.
Test.case
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:ButtonGroup ID="ButtonGroup1" runat="server" Title="" Columns="3">
<Items>
<ext:SplitButton ID="SplitButton1" runat="server"
Text="Users" IconCls="add" IconAlign="Top"
ArrowAlign="Bottom" Width="60" Scale="Large" RowSpan="3">
<Listeners>
<Click Handler="#{Panel1}.load('TestCase2.aspx');" />
</Listeners>
</ext:SplitButton>
<ext:SplitButton ID="SplitButton2" runat="server"
Text="Users2" IconCls="add" IconAlign="Top"
ArrowAlign="Bottom" Width="60" Scale="Large" RowSpan="3">
<Listeners>
<Click Handler="#{Panel1}.load('TestCase3.aspx');" />
</Listeners>
</ext:SplitButton>
</Items>
</ext:ButtonGroup>
<ext:Panel ID ="Panel1" runat="server" Title="Loading on show">
<Loader ID="Loader1"
runat ="server"
Url =""
Mode ="Frame"
>
<LoadMask ShowMask="true" />
</Loader>
</ext:Panel>
</asp:Content>
TestCase2
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form2" runat="server">
here is the test case
</form>
</body>
</html>
TestCase3
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form3" runat="server">
here is the test case
</form>
</body>
</html>
*also u need to change form id of each loaded page as conflict happened.It is the key point I guess.(I tested and it works fine)

Google app engine and primefaces layout/layoutunit does not work

I'm working with primefaces and google app engine. I am posting this code because the layouts do not work.
Initially I tried to use the template facelets (composition, include, insert, sets) and neither worked. I am familiar with facelets and jsf as work with them in another environment.
So I decided to try the layout and layouunit, but nothing.
Thank you.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Inicio</title>
</head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="top" height="75" header="Top">
<h:outputText value="North unit content1aaaa." />
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form>
This fullPage layout consists of five different layoutUnits which are
resizable and closable by default.
</h:form>
</p:layoutUnit>
<p:layoutUnit position="bottom" height="75" header="Bottom">
<h:outputText value="South unit content." />
</p:layoutUnit>
</p:layout>
</h:body>
</f:view>
</html>
You have some Errors in your Code.
The value of LayoutUnits must not be top or bottom. Allowed values are:
<p:layoutUnit position="north"/>
<p:layoutUnit position="west"/>
<p:layoutUnit position="east"/>
<p:layoutUnit position="south"/>
Second thing is about
<f:view contentType="text/html">
Don't include all your content under this Tag. Just close it directly (if it's really needed)
<f:view contentType="text/html"/>
Then you have to edit your head Tags to
<h:head>...</h:head>
Just refer to the Primefaces Example: http://www.primefaces.org/showcase/ui/layoutFull.jsf
Here's your working Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Inicio</title>
</h:head>
<h:body>
<p:layout fullPage="true">
<p:layoutUnit position="north" height="75" header="Top">
<h:outputText value="North unit content1aaaa." />
</p:layoutUnit>
<p:layoutUnit position="center">
<h:form>
This fullPage layout consists of five different layoutUnits which are
resizable and closable by default.
</h:form>
</p:layoutUnit>
<p:layoutUnit position="south" height="75" header="Bottom">
<h:outputText value="South unit content." />
</p:layoutUnit>
</p:layout>
</h:body>
</html>

Resources