Skip to content

Instantly share code, notes, and snippets.

View ova2's full-sized avatar

Oleg Varaksin ova2

View GitHub Profile
@ova2
ova2 / bugCSV
Last active August 29, 2015 13:57
Bug in CSV with date / time converter
Client-side conversion / validation fails in most cases for f:convertDateTime and valid dates / times
PrimeFaces 4.x (current)
The client-side converter for f:convertDateTime uses $.datepicker.parseDate(format, value, settings).
The problem with $.datepicker.parseDate ist an exception when the format doesn't have days
(works as designed). E.g. try to parse $.datepicker.parseDate("mm/y", "11/16").
An exception will be raised. "mm/y" for datepicker is exactly the pattern "MM/yy" in
f:convertDateTime. Simple attach e.g. <f:convertDateTime pattern="MM/yy" timeZone="..."/>
to p:inputText and use CSV. The date will be always invalid.
@ova2
ova2 / gist:2821224
Created May 28, 2012 21:08
PickList with Filter (Java)
protected void encodeMarkup(FacesContext context, PickList pickList) throws IOException {
...
writer.startElement("tbody", null);
// FILTER EXTENSION BEGIN
if (pickList.isShowSourceFilter() || pickList.isShowTargetFilter()) {
if (pickList.isShowSourceControls()) {
writer.startElement("td", null);
writer.endElement("td");
@ova2
ova2 / gist:2821227
Created May 28, 2012 21:11
PickList with Filter (CSS)
.ui-picklist-source-filter input,
.ui-picklist-target-filter input {
background: #ffffff url("#{resource['img:filter.png']}?rv=${buildNumber}") no-repeat scroll 98% !important;
width: 95%;
}
@ova2
ova2 / gist:2821226
Created May 28, 2012 21:09
PickList with Filter (JavaScript)
PrimeFaces.widget.PickList.prototype.filter = function(input, source) {
var $pkitems = source ? this.sourceList : this.targetList;
var escapedInput = input.value.replace(/([()[{*+.$^\\|?])/g, '\\$1');
var re = new RegExp(escapedInput, "i");
$pkitems.find(".ui-picklist-item").show().filter(
function() {
return !re.test(jQuery(this).text());
}).hide();
}
@ova2
ova2 / badwidget.js
Created August 17, 2012 11:23
PrimeFaces DefaultCommand Issue
PrimeFaces.widget.DefaultCommand = PrimeFaces.widget.BaseWidget.extend({
init: function(cfg) {
...
//attach keypress listener to parent form
this.jqTarget.parents('form:first').keydown(function(e) {
...
});
});
@ova2
ova2 / focus.xhtml
Created August 17, 2012 15:18
Context for Focus is ignored
<p:messages/>
<p:focus context="secondGrid"/>
<h:panelGrid columns="2" style="margin-bottom:10px;">
<h:outputLabel value="Dummy *"/>
<p:inputText required="true" label="Dummy"/>
</h:panelGrid>
<h:panelGrid id="secondGrid" columns="2">
@ova2
ova2 / solutionPerfProblemDataTable.js
Created September 27, 2012 11:40
Solution to "DataTable performance problem in IE with checkboxes / radio buttons"
bindCheckboxEvents: function() {
...
SOLUTION TO THE PERFORMANCE PROBLEM
//keyboard support
$(checkboxSelector).off('focus.ui-chkbox blur.ui-chkbox keydown.ui-chkbox keyup.ui-chkbox')
.on('focus.ui-chkbox', function() {
var input = $(this),
box = input.parent().next();
@ova2
ova2 / perfProblemDataTable.js
Created September 27, 2012 10:09
DataTable performance problem in IE with checkboxes / radio buttons
bindCheckboxEvents: function() {
...
A HUGE PERFORMANCE PROBLEM WITH THE CODE BELOW
//keyboard support
$(document).off('focus.ui-chkbox blur.ui-chkbox keydown.ui-chkbox keyup.ui-chkbox', checkboxInputSelector)
.on('focus.ui-chkbox', checkboxInputSelector, null, function() {
var input = $(this),
box = input.parent().next();
public class MyTestIT extends AbstractSeleniumTest {
@FlowOnPage(step = 1, desc = "Description for this method")
void flowSomePage(SomePage somePage) {
...
}
@FlowOnPage(step = 2, desc = "Description for this method")
void flowAnotherPage(AnotherPage anotherPage) {
...
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface FlowOnPage {
int step() default 1;
String desc();
}