Skip to content

Commit

Permalink
Fixing jsf.ajax -> faces.ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
cuioss committed Jun 14, 2024
1 parent 0a7c294 commit ae4840e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
package de.cuioss.jsf.api.components.base;

import de.cuioss.jsf.api.components.partial.*;
import lombok.experimental.Delegate;

import jakarta.faces.component.StateHelper;
import jakarta.faces.component.UIComponent;
import jakarta.faces.component.html.HtmlSelectBooleanCheckbox;
import jakarta.faces.context.FacesContext;
import lombok.experimental.Delegate;

/**
* Minimal super-set for cui-based components that are at least
* Minimal superset for cui-based components that are at least
* {@link HtmlSelectBooleanCheckbox}.
* Therefore, it provides the handling of the
* styleClass and style attribute and the implicit attributes provided by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import de.cuioss.jsf.bootstrap.BootstrapFamily;
import de.cuioss.jsf.bootstrap.common.partial.ColumnProvider;
import de.cuioss.tools.collect.MapBuilder;
import lombok.experimental.Delegate;
import org.omnifaces.util.State;

import jakarta.faces.component.FacesComponent;
import jakarta.faces.component.behavior.ClientBehavior;
import jakarta.faces.event.ComponentSystemEvent;
import jakarta.faces.event.ListenerFor;
import jakarta.faces.event.PreRenderComponentEvent;
import lombok.experimental.Delegate;
import org.omnifaces.util.State;

import java.io.Serializable;
import java.util.*;

Expand Down Expand Up @@ -215,7 +215,7 @@ public StyleClassBuilder getStyleClassBuilder() {
*/
public Map<String, Object> resolvePassThroughAttributes() {
return new MapBuilder<String, Object>().putAll(getPassThroughAttributes())
.put(DATA_SWITCH_DISABLED, String.valueOf(isDisabled())).toImmutableMap();
.put(DATA_SWITCH_DISABLED, String.valueOf(isDisabled())).toImmutableMap();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let intitializeInputGuards = function () {

let updateTarget = guardInput.data('cui-ajax-update');
let processTarget = guardInput.data('cui-ajax-process');
jsf.ajax.request(guardInput.attr('id'), null, {
faces.ajax.request(guardInput.attr('id'), null, {
execute: processTarget,
target: guardInput.attr('id'),
render: updateTarget,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
let intitializeNotificationbox = function () {
jQuery('.alert-dismissible > [data-dismiss="alert"][data-dismiss-listener="true"]').each(function () {
$(this).parent().one('close.bs.alert', function () {
jsf.ajax.request($(this).attr('id'), null, {execute: '@this'});
faces.ajax.request($(this).attr('id'), null, {execute: '@this'});
})
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let cuiUpdateCollapsiblePanelServerState = function (panelId, isExpanded, event)
options["render"] = panelId; //re-render component
options[panelId + "_isexpanded"] = isExpanded;

jsf.ajax.request(panelId, null, options);
faces.ajax.request(panelId, null, options);
if (event) {
event.stopPropagation();
}
Expand All @@ -43,7 +43,7 @@ let cuiUpdateCollapsiblePanelState = function (panelId, isExpanded, event) {
/**
* This is called for each AJAX request/response and after page load.
* Adding bootstrap collapse/expand listeners to all panel components.
* After a click the collapse state is updated immediately.
* After a click, the collapse state is updated immediately.
* If the component has asynUpdate=true the server state is updated after full expand/collapse.
*/
let intitializeCuiPanelUpdate = function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
///<reference path='typings/bootstrap.d.ts'/>

namespace Cui.Core {
/**
* Extracts the get (or search) data from a given URL
* @param {string} url a URL that might contain parameterUrl
* @return {Object} get all the get variables as properties
**/

/**
* Extracts the get (or search) data from a given URL
* @param {string} url a URL that might contain parameterUrl
* @return {Object} get all the get variables as properties
**/
export function getData(url: string): any {
let match: any;
let search: RegExp = /([^&=]+)=?([^&]*)/g;
Expand All @@ -24,7 +24,7 @@ namespace Cui.Core {
let data: any = {};
/* jshint ignore:start */
while (match = (<any>search).exec(query))
/* jshint ignore:end */
/* jshint ignore:end */
data[decode(match[1])] = decode(match[2]);

return data;
Expand All @@ -38,8 +38,7 @@ namespace Cui.Core {
let currentValue = this.trim(jQuery(input).val());
if (currentValue !== undefined && currentValue.length >= maxLength) {
moreLengthAction();
}
else {
} else {
lessLengthAction();
}
}
Expand All @@ -50,7 +49,7 @@ namespace Cui.Core {

/**
* Display an ajax error message by showing the invisible notification box for 5 seconds
**/
**/
function handleAjaxError(): void {
$('.cui-ajax-error-message').show();
setTimeout(() => {
Expand All @@ -60,13 +59,13 @@ namespace Cui.Core {

/**
* Register for ajax errors (jsf standard + PrimeFaces)
**/
**/
export function addErrorMessage(): void {
if (typeof jsf !== "undefined") {
jsf.ajax.addOnError((data: any) => {
if (typeof faces !== "undefined") {
faces.ajax.addOnError((data: any) => {
handleAjaxError();
});
$(document).on("pfAjaxError", function(event: any, xhr: { [x: string]: string; }, options: any) {
$(document).on("pfAjaxError", function (event: any, xhr: { [x: string]: string; }, options: any) {
const statusText = 'statusText';
if (xhr[statusText] != 'abort') {
handleAjaxError();
Expand All @@ -80,14 +79,13 @@ namespace Cui.Core {
let position: number = $(window).scrollTop();
if (position >= 200) {
$('#scroll-to-top').attr('style', 'bottom:8px;');
}
else {
} else {
$('#scroll-to-top').removeAttr('style');
}
});
}
/**

/**
* Register a component enabler to be called immediate and after each AJAX update.
* Should be called at document.ready.
* Warning: Event listeners in the callback can get attached multiple times therefore.
Expand All @@ -96,11 +94,11 @@ namespace Cui.Core {
*
* @param callback
**/
export function registerComponentEnabler(callback?:() => void):void {
export function registerComponentEnabler(callback?: () => void): void {
callback();
// Ensure jsf ajax will react properly
if (typeof jsf !== "undefined") {
jsf.ajax.addOnEvent((data: { status: string; }): void => {
if (typeof faces !== "undefined") {
faces.ajax.addOnEvent((data: { status: string; }): void => {
if (data.status && data.status === 'success') {
callback();
}
Expand All @@ -109,18 +107,20 @@ namespace Cui.Core {
// Catch all PF ajax events
jQuery(document).on("pfAjaxComplete", callback);
}

let onIdle: Array<() => void> = [];

export function registerOnIdle(callback?:() => void):void {
export function registerOnIdle(callback?: () => void): void {
onIdle.push(callback);
}
export function executeOnIdle():void {

export function executeOnIdle(): void {
jQuery('.modal').modal('hide');
jQuery('[data-modal-dialog-id=confirmDialogTimeout]').modal('show');
jQuery(document.body).addClass('modal-timeout');
onIdle.forEach((callback:() => void) => { callback(); });
onIdle.forEach((callback: () => void) => {
callback();
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ namespace Cui {
const hasJSClickEvents: boolean = jQuery(keyBound).is("[onclick]");
if (hasJQClickEvents || hasJSClickEvents) {
jQuery(keyBound).trigger("click");
}
else {
} else {
window.location.href = jQuery(keyBound).attr("href");
}
}
Expand All @@ -36,7 +35,10 @@ namespace Cui {
* NAME: Bootstrap 3 Triple Nested Sub-Menus
* This script will active Triple level multi drop-down menus in Bootstrap 3.*
*/
jQuery('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event: { preventDefault: () => void; stopPropagation: () => void; }) {
jQuery('ul.dropdown-menu [data-toggle=dropdown]').on('click', function (event: {
preventDefault: () => void;
stopPropagation: () => void;
}) {
// Avoid following the href location when clicking
event.preventDefault();
// Avoid having the menu to close when clicking
Expand Down Expand Up @@ -105,7 +107,7 @@ namespace Cui {
icon.toggleClass("cui-icon-triangle_s", collapsed);
if (Cui.Utilities.parseBoolean(asyncUpdate)) {

jsf.ajax.request(jQuery(parent).attr('id'), null, { execute: '@this' });
faces.ajax.request(jQuery(parent).attr('id'), null, {execute: '@this'});
}
if (callback) {
callback();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ interface JsfStatic {
ajax:JsfAjax;
}

declare var jsf: JsfStatic;
declare var faces: JsfStatic;

0 comments on commit ae4840e

Please sign in to comment.