Using jsf2 (see maven dependencies)
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.10</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.10</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
</dependency>
I found out that configuration of jsf doesn't be used by ui:repeat tag. If I redefine the separator char in web.xml
<context-param>
<param-name>javax.faces.SEPARATOR_CHAR</param-name>
<param-value>_</param-value>
</context-param>
a <ui:repeat> renderes a : anyway, this is why I can't use jquery for finding a div's Id in my custom component:
<a href="#" onclick="toggleDiv('#{cc.clientId}Div')">
<h:outputText value="#{cc.attrs.value}" />
</a>
<div id="#{cc.clientId}Div" style="display: none">...</div>
The HTML result of this component is:
123456
<div id="j_idt12:0_j_idt18_0_j_idt24Div" style="display: none">
...
</div>
As you can see, there's a : in j_idt12:0_j... that makes jquery functions invalid. What can I do about it? Is there a way to set a special ui separator char?
As to the jQuery "problem", just escape : as \\: or use the [id] selector instead. See also How to select JSF components using jQuery? By the way, I'd rather use fixed IDs instead of relying on JSF-generated IDs, otherwise your webapp is highly unportable.
As to the <ui:repeat> problem, sorry, I can't reproduce it. But that Facelets 1.x dependency is highly suspicious. It would possibly only conflict with Facelets 2.x which is already bundled in JSF 2.x which in turn can indeed explain this problem. Get rid of that Facelets 1.x dependency altogether, you don't need it when already using JSF 2.x.
Related
Highcharts charts svg should be rendered using htmlunit-driver same as it is any other browser like chrome, edge, firefox etc
But the charts rendered are too small. Generated svg has a few NaN in the width attributes of couple rect tags. Moreover linearGradient and clipPath tags are all lowercased in the svg.
I have copied my sample project jdoodle. But it is not able to download maven dependencies. Anyways you can check my code for reference and copy the project to your local to run it:
https://www.jdoodle.com/ia/BEk
Brief structure of my example project:
highcharts-export.html (My custom html file to be used by htmlunitt)
highcharts-export.js (My custom js file to be used by htmlunit)
highcharts and highcharts-more js files
HighchartsExport.java the java code which uses selenium and htmlunit to execute the above html/js code to generate highcharts chart.
maven deps:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.7.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>4.7.2</version>
</dependency>
</dependencies>
I have jsf validation on form where the invalid fields are highlighted based on
styleClass="#{component.valid ? 'reportInput' : 'reportInput_invalid'}"
and a tooltip is being used for displaying the error message as follows
<p:tooltip for="inputFieldId">
<p:message for="inputFieldId" />
</p:tooltip>
Everything works as expected but i want to improve user experience and want to introduce pure client side validation using
<p:clientValidator />
I tried this but it didnt work when onBlur event is fired on inputfield i got the following JS error
'null' is Null or no Object
in validation.js.jsf and the line code is
d.data("uiMessageId",b.attr("id"))
Is it possible to achieve?
An example of my input field is:
<p:inputText id="bic"
styleClass="#{component.valid ? 'reportInput' : 'reportInput_invalid'}"
value="#{bean.bic}"
required="true" requiredMessage="Field value is required" >
<p:watermark for="bic" value="CMHJKLIL" />
<pe:keyFilter regEx="/[a-z0-9]/i" />
<f:validateLength minimum="8" />
<p:clientValidator/>
</p:inputText>
I am using Primefaces 4 with the following maven dependency
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
Here as it looks in jsf page head section
Here is the validation.js file that is being used
validatuion.js here
i had the exact same error.
it seems that the validator.js code searches for a message container attached to the field, and, if cant find one, it searches one in the nearest form "e.findUIMessage(a,d.closest("form").find("div.ui-message"))"
what you need is to have an tag,
that is, a message assigned for the inputtext, so, when the validator generates an error, it can post the text in that message container.
We are upgrading from jsf 1.2 to jsf 2.
We are using apache myfaces 2.1 and rich faces 4.3.
We have onload-phase listener configured like below (for JSF 1.2)
web.xml :
<context-param>
<param-name>onload-config</param-name>
<param-value>/WEB-INF/onload-config.xml</param-value>
</context-param>
and corresponding phase listener configured in faces-config.xml as :
<lifecycle>
<phase-listener>net.sf.jsfcomp.ext.onload.OnLoadPhaseListener</phase-listener>
<lifecycle>
We are using same configuration as is for migrating to JSF 2 and as I know we don't need to include any extra jar for above set up to work.
(jsf implementation and commons-logging jars are the only pre-requisites)
However when a url is clicked which is to invoke an action method for configuration in onload-config.xml as below :
<navigation-rule>
<view-id>/from-page.xhtml</view-id>
<action>#{bean.action}</action>
</navigation-rule>
bean.action is not getting invoked and resource not found error is returned.
Am i missing any configuration ? or do i need to add any extra libs ?
Please help.
EDIT 1 :
Adding more details for the issue :
The page being rendered after bean.action method is returned is as below :
<ui:composition>
<a4j:form id="sample-Form">
<ui:include src="#{bean.panel}">
</ui:include>
<h:commandButton id="button1" value="Go" action="#{bean.next}"/>
</a4j:form>
</ui:composition>
where on clicking the next button , same page is rendered with dynamic panel name (bean.panel) returned from back end
How could you invoke a JSF2 composite (widget) within anothers composite's implementation tag?
When I do so, I get the following error: /resources/widgets/tileContainer.xhtml #25,45 <mywidgets:tileContainer> Tag Library supports namespace: http://java.sun.com/jsf/composite/widgets, but no tag was defined for name: tileContainer
The code snippet is:
<composite:interface name="tileContainer">
<composite:attribute name="pubCategoryId" type="java.lang.Long" required="true" />
</composite:interface>
<composite:implementation>
<div class="tileContainer">
<ui:repeat value="#{pubController.getPubsByCategory(cc.attrs.pubCategoryId)}" var="pub">
#{pub.title}
<mywidgets:tileContainer title="Private">
<mywidgets:tileSmallPictureTitle
title="Bulk Dispatch Lapse stressed with application protocols">
</mywidgets:tileSmallPictureTitle>
</mywidgets:tileContainer>
</ui:repeat>
</div>
</composite:implementation>
Any other design recommendations on how to handle this?
Thank you for sharing your thoughts.
This is recognizable as Mojarra issue 2437 which was fixed in Mojarra 2.1.10 (released 25 july 2012). It look like you're using a rather outdated Mojarra version. It's currently already at 2.1.25 (2.2.x is even already out, but I wouldn't recommend switching to 2.2 right now, let them fix all childhood diseases first).
Okay, I moved the namespace declaration of my composite directory from the <html xmlns... tag down to the <composite:implementation> tag.
So the composite looks like this:
<composite:implementation xmlns:mywidgets="http://java.sun.com/jsf/composite/widgets">
Otherwise, the namespaces of the parent and child composite will resolve wrongly.
I have a composite component that takes a specific object type as its value attribute. It looks like this:
<cc:interface>
<cc:attribute name="value"
type="com.myapp.Tally"
required="true"
</cc:interface>
The component merely produces a h:panelGrid with data elements from the object.
I have never had trouble with it until I tried using it inside a ui:repeat structure like this:
<ui:repeat value="#{myApp.tallyList}" var="tally">
<p>
<qc:tallySummaryH value="#{tally}" />
</p>
</ui:repeat>
When this page is requested, it throws an exception:
javax.faces.view.facelets.TagException: /table.xhtml #86,66 <qc:tallySummaryH> The following attribute(s) are required, but no values have been supplied for them: value.
at com.sun.faces.facelets.tag.composite.InterfaceHandler.validateComponent(InterfaceHandler.java:233)
at com.sun.faces.facelets.tag.composite.InterfaceHandler.apply(InterfaceHandler.java:125)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:98)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:152)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyCompositeComponent(CompositeComponentTagHandler.java:349)
Other references to #{tally} inside the ui:repeat loop do not have any problem. They operate as expected. Is this a Mojarra bug or is there something in the JSF specification I didn't understand?
This is on Mojarra 2.1.0 (FCS 2.1.0-b11) in GlassFish 3.1.1
This is related to a bug which was fixed in Mojarra 2.1.1. Consider upgrading. I believe it's (in)directly the result of the visit hint fixes as mentioned in this overview of issues fixed in Mojarra 2.1.1.