Questions and answers
If you need help about ZnetDK for Mobile, please post your questions on the SOURCEFORGE Discussion page of ZnetDK by clicking the button below.
Hello,
The new version 2.9 of ZnetDK is released.
To get all changes and bug fixes, see CHANGELOG page.
Pascal,
ZnetDK developer
Hello,
The ZnetDK 4 Mobile website was updated this week with new code snippets for Multiple selection in a form.
See the step-by-step procedure to add this functionality to the ZnetDK 4 Mobile Starter application.
Hoping you'll enjoy,
Pascal
ZnetDK developer.
Hello,
The new version 2.8 of ZnetDK is released.
To get all changes and bug fixes, see CHANGELOG page.
Pascal,
ZnetDK developer
Hello,
The ZnetDK 4 Mobile website was updated this week with new code snippets for Uploading files from your Application.
See the step-by-step procedure to add this functionality to the ZnetDK 4 Mobile Starter application.
Hoping you'll enjoy,
Pascal
ZnetDK developer.
Hello,
The new version 2.7 of ZnetDK is released and includes the following changes and bug fixes:
beforeshow
) and after (aftershow
) displaying a modal dialog. If the beforeshow
event handler returns false
, the modal dialog is not displayed.setCustomValidity
method) when an input field value is incorrect.znetdkMobile.install.showInstallView()
and znetdkMobile.install.showUninstallView()
.CFG_MOBILE_INSTALL_MESSAGE_DISPLAY_AUTO
parameter to enable or disable automatic display of a message to install the application (Add 2 Home Screen). Set to TRUE by default, this value can be changed to FALSE
in the config.php
script of the application. This message can also be displayed on demand by calling the znetdkMobile.install.showInstallableMessage()
method.znetdkMobile.install.isAppInstallable()
and znetdkMobile.install.isAppInstalled()
methods respectively to know if the application is installable and if it is already installed.viewName
and onViewLoaded
optional parameters added to the znetdkMobile.modal.make()
method in order to load in Ajax the modal dialog from the specified ZnetDK view before instantiating it. If the modal dialog already exists in the DOM, it is not loaded again when the method is called next times.znetdkMobile.serviceWorker.isRegistered
property that is set to true once the service worker registration has succeeded.znetdkMobile.browser.doPhoneCall()
method to dial the specified phone number on cell phone.znetdkMobile.browser.sendSMS()
method to open the screen for sending an SMS and pre-fill phone number and message from the specified values passed in parameters.CFG_CHECK_PWD_VALIDITY
and LC_MSG_ERR_PASSWORD_BADLENGTH
PHP constants for customization purpose).$includeArchived
parameter (set to TRUE
by default) added to the \UserManager::getUsersHavingProfile()
method. When set to FALSE
, archived users are excluded from the returned users.znetdkMobile.list.beforeInsertRowCallback
property to define a custom function to call each time a row is inserted in a list. This function has one parameter which contains the data to display for the row. This data can be modified within the function before displaying the row. This callback function can be useful to format data before row insertion.znetdkMobile.autocomplete
input field when the previously entered keyword does not match any suggestions.znetdkMobile.autocomplete
input field can be cached in memory to reduce network traffic. To enable caching, set znetdkMobile.autocomplete.maxNumberOfCachedItems
to a value greater than zero (set to zero by default). To clear the cache once a suggestion is selected, change the value znetdkMobile.autocomplete.cacheLifetime
to 'selection'
('page'
is set by default, meaning that cache is kept until user leaves the application).DAO::store()
method with an empty row id value (i.e. '') and the $emptyValuesToNull
parameter is FALSE
(default case), then the SQL statement generated is no longer an UPDATE
but an INSERT
instead.znetdkMobile.messages.add()
method were not hidden after the user logged out.$loginName
is renamed to $userId
for the \UserManager::getUserProfiles()
method because the expected parameter value was the user internal identifier.znetdkMobile.autocomplete.make()
method did not returned a string value.znetdkMobile.log.e$()
function that is not defined when a JS error is detected after a view loading through the znetdkMobile.ajax.loadView()
method (issue in minification of mobile-min.js
version 2.6).Pascal,
ZnetDK developer
Bonjour,
Vous pouvez vous inspirer de l'exemple d'application Autocomplete publiée sur la page Code Snippets.
La fonction de rappel (voir le paramètre onSelect
de la méthode znetdk.autocomplete.make()
dans la documentation en ligne de l'API JS) à la sélection d'une suggestion est l'endroit qui convient pour charger dynamiquement le contenu de votre liste déroulante via un appel Ajax en utilisant la méthode znetdkMobile.ajax.request()
(voir documentation en ligne de l'API JS).
Bien à vous
Pascal
Hello,
The new version 2.6 of ZnetDK is released and includes the following changes and bug fixes:
cache=true
GET parameter is added to the download url.\General::reducePictureSize()
method that resizes a JPEG or PNG picture by specifying a maximum width and height.CFG_APPLICATION_VERSION
parameter to specify the current application's version (integer value, 1 by default). When this version is set into the config.php
of the application, the client-side application is automatically reloaded on user's session expiration if the application version on the server-side is higher than the one currently loaded in the user's web browser.\Convert::binaryToBase64Url()
ZnetDK method to convert a binary file content to base64 URL.\Convert::base64UrlToBinary()
ZnetDK method to convert a base64 URL to binary file content.\Request::setTrimedCharacters()
to specify the characters to trim when retrieving the sanitized value of a request parameter. By default, the trimed characters are " \n\r\t\v\x00". This method can be useful to preserve the newline characters of the beginning and the end of a text.CFG_REQUEST_VARIABLE_FILTERING_LEVEL
parameter to specify the filtering level applied by default when reading HTTP request variables by calling the\Request()
getter method (i.e $request->my_var
). Value 'HIGH'
is set by default (PHP filter_var()
function is applied with FILTER_SANITIZE_STRING
filter and FILTER_FLAG_NO_ENCODE_QUOTES
option). Other allowed value is 'LOW'
(PHP strip_tags()
function is applied and the string '<=' is preserved if exists in the text to filter).\Request::setVariableFilteringLevel()
to change the default value set through the CFG_REQUEST_VARIABLE_FILTERING_LEVEL
parameter. Allowed parameters are 'LOW'
and 'HIGH'
.CFG_MOBILE_JQUERY_JS PHP
constant).znetdkMobile.setInputValue()
method now allows to check multiple checkboxes having the same name (generally ended with double brackets, for example "mycheckboxes[]"
). The values of the checkboxes to check are passed in parameter of the method as an array.znetdkMobile.getInputValue()
method now allows to retrieve as a JS array, the selected values for a SELECT
HTML element set with the multiple
property.znetdkMobile.getInputValue()
method when the input name passed in parameter contains "bracket" symbols.'z4musers.php'
) was not properly paginated (same users were displayed several times).Pascal,
ZnetDK developer
Bonsoir,
J’ai besoin d’aide sur une action que je veux effectuer avec ZnetDK Mobile.
Dans ma boite de dialogue d’enregistrement, j’utilise une balise select mais il se fait que le nombre de produit est trop élevé et ça prend du temps pour trouver un produit. Alors j’ai pensé à mettre dans le modal, un input auto-complete qui remplira un autre input avec le ID du produit lorsqu’un des labels proposés sera sélectionné.
Merci pour votre aide.
Bonjour,
J'ai testé et ça marche exactement comme je voulais.
Merci Bien.
Bonjour,
L'application de démarrage ZnetDK 4 Mobile est configurée par défaut pour être une application à page unique (Single Page Application).
Cela signifie que la page principale de l'application (unique) n'est jamais rechargée lorsque l'utilisateur réalise une action. Le contenu de la page affichée dans le navigateur (le DOM) est complété de données ou d'éléments HTML supplémentaires au fur et à mesure que l'utilisateur accède à de nouvelles vues de l'application.
Pour votre exemple de navigation depuis une liste de pays vers une liste des villes correspondantes au clic d'un pays, il n'existe pas de solution prête à l'emploi dans ZnetDK.
Néanmoins, pour répondre à ce besoin, voici par exemple comment je procéderais (il s'agit d'une solution possible parmi beaucoup d'autres) :
1) Déclarer 2 vues dans le script menu.php de l'application : une vue mycountryview
pour afficher les pays (menu Pays) et une vue mycityview
pour afficher les villes (menu Villes).
<?php /* Définition menu.php */ namespace app; class Menu implements \iMenu { static public function initAppMenuItems() { \MenuManager::addMenuItem(NULL, 'mycountryview', 'Pays', 'fa-globe'); \MenuManager::addMenuItem(NULL, 'mycityview', 'Villes', 'fa-map-marker'); } }
2) Ensuite, depuis la vue Pays (mycountryview.php
), coder un gestionnaire d'événements répondant au clic d'une ligne de la liste des pays.
Dans ce gestionnaire, mémoriser l'identifiant du pays correspondant à la ligne cliquée et demander l'affichage de la vue Villes (méthode znetdkMobile.content.displayView()).
<!-- Vue mycountryview.php --> <ul id="countrylist" class="w3-ul w3-hide" data-zdk-load="mycontroller:countries"> <li><a href="{{country_id}}">{{country_name}}</a></li> </ul> <script> console.log('** mycountryview **'); znetdkMobile.list.make('#countrylist'); $('#countrylist').on('click', 'a', function(event){ event.preventDefault(); // Clicked Country is memorized var countryId = $(this).attr('href'); $('#countrylist').data('selected-country-id', countryId); // The city view is displayed znetdkMobile.content.displayView('mycityview'); }); </script>
3) Dans la vue Villes (mycityview.php
), après initialisation en JS de la liste des villes (méthode znetdkMobile.list.make()), personnaliser la fonction de rappel beforeSearchRequestCallback pour passer en paramètre POST (country_id
) de la recherche de villes, l'identifiant du pays mémorisé à l'étape 2.
<!-- Vue mycityview.php --> <ul id="citylist" class="w3-ul w3-hide" data-zdk-load="mycontroller:cities"> <li>{{city_name}}</li> </ul> <script> console.log('** mycityview **'); var myCityList = znetdkMobile.list.make('#citylist'); myCityList.beforeSearchRequestCallback = function(requestData) { var countryId = $('#countrylist').data('selected-country-id'); requestData.country_id = countryId; }; </script>
4) Dans le contrôleur en charge de retourner la liste des villes, lire le paramètre POST (country_id
) et ne retourner que les villes correspondantes.
<?php /* Contrôleur mycontroller.php */ namespace app\controller; class MyController extends \AppController { static protected function action_countries() { $countries = [ ['country_id' => 'fr', 'country_name' => 'France'], ['country_id' => 'uk', 'country_name' => 'Royaume-uni'], ['country_id' => 'es', 'country_name' => 'Espagne'], ['country_id' => 'it', 'country_name' => 'Italie'], ]; $response = new \Response(); $response->rows = $countries; $response->total = count($countries); return $response; } static protected function action_cities() { $allCities = [ ['country_id' => 'fr', 'city_id' => 'fr1', 'city_name' => 'Paris'], ['country_id' => 'fr', 'city_id' => 'fr2', 'city_name' => 'Lyon'], ['country_id' => 'fr', 'city_id' => 'fr3', 'city_name' => 'Marseille'], ['country_id' => 'uk', 'city_id' => 'uk1', 'city_name' => 'London'], ['country_id' => 'uk', 'city_id' => 'uk2', 'city_name' => 'Manchester'], ['country_id' => 'uk', 'city_id' => 'uk3', 'city_name' => 'Glasgow'], ['country_id' => 'es', 'city_id' => 'es1', 'city_name' => 'Madrid'], ['country_id' => 'es', 'city_id' => 'es2', 'city_name' => 'Barcelone'], ['country_id' => 'es', 'city_id' => 'es3', 'city_name' => 'Grenade'] ]; $cities = []; $request = new \Request(); if ($request->country_id !== NULL) { foreach ($allCities as $city) { if ($city['country_id'] === $request->country_id) { $cities[] = $city; } } } else { $cities = $allCities; } $response = new \Response(); $response->rows = $cities; $response->total = count($cities); return $response; } }
En espérant vous avoir aidé.
Pascal MARTINEZ
ZnetDK developer