Zafir.UI.Next not working with IE11 - websharper

Beginning with Zafir.UI.Next Version 4.0.128.30.beta6 there is an
jQuery.Deferred exception with IE11:
jQuery.Deferred exception: Die Eigenschaft "insertBefore" eines undefinierten oder Nullverweises kann nicht abgerufen werden. TypeError: Die Eigenschaft "insertBefore" eines undefinierten oder Nullverweises kann nicht abgerufen werden.
at DomUtility.InsertAt (WebSharper.UI.Next.js:423:96)
at Docs$1.InsertNode (WebSharper.UI.Next.js:3933:3)
at Docs$1.InsertDoc (WebSharper.UI.Next.js:3926:3)
at Docs$1.LinkPrevElement (WebSharper.UI.Next.js:3879:3)
at Doc.RunBetween (WebSharper.UI.Next.js:5452:3)
at Doc.RunBefore (WebSharper.UI.Next.js:5447:3)
at ReplaceInDom (WebSharper/WebSharper.UI.Next.js:3942:4)
at a (WebSharper.Main.js:1264:7)
at Anonymous function (WebSharper.Main)
SCRIPT5007: Die Eigenschaft "insertBefore" eines undefinierten oder Nullverweises kann nicht abgerufen werden.
jquery-3.1.1.js (3855,3)
The project's server part is like this:
public class Server
{
[Website]
public static Sitelet<object> Main => new SiteletBuilder().With<string>
((ctx, endpoint) => Content.Page(
Head:
doc(
link(attr.href("Content/bootstrap.css"), attr.rel("stylesheet"), attr.type("text/css")),
script(attr.src("Scripts/jquery-3.1.1.js"), attr.type("text/javascript")),
script(attr.src("Scripts/jquery.stickytableheaders.js"), attr.type("text/javascript"))
),
Body:
doc(
client(() => Client.Main(endpoint))
)
).Install();
And the client like this:
public static IControlBody Main(string endpoint) {return div( ...);}
This works flawlessly with e.g. Chrome and Edge.
What is wrong with this? Is there a bug?
Any hint is highly appreciated.
EDIT:
I identified the offending piece of code in WebSharper.UI.Next.js of Version 4.0.132.34-beta6.
This works in both EGDE and Chrome, but not in IE11:
Docs$1.LinkPrevElement=function(el,children)
{
var v;
v=Docs$1.InsertDoc(el.parentElement,children,el);
};
I changed the code to read:
Docs$1.LinkPrevElement=function(el,children)
{
var v;
v=Docs$1.InsertDoc(el.parentNode,children,el);
};
This works in EDGE, Chrome and IE11.
Could somebody please shed some light on this?
EDIT 2:
This discourages the use of parentElement: What is this.parentElement?

Apparently this has been fixed in WebSharper 4 beta-7: https://github.com/intellifactory/websharper.ui.next/issues/117
Btw, I used this in post-build to correct the generated script(s):
powershell -c "gci $(ProjectDir)Scripts\WebSharper\*.js -recurse | foreach {(gc $_ | foreach {$_ -replace 'parentElement', 'parentNode'}) | sc $_}"
Many Thanks.

Related

RapidClipse X - PopupView

As there's still no manual for migration from RC-4 to RC-X its not easy to create new projects or migrate the old ones.
Does anyone know how to show a PopupView to edit something and to close it again in the popup class after finished activities or on cancel?
different other conceptional changes like grid, item.writebean.... I already solved. But for Popup cant find similar solution.
thanks in advance for every hint.
What I would do is create a new GUI-Element that inherits from Dialog. This view can then be designed with the GUI-Builder. To then show the dialog all you have to do is to create a new instance and then call the open() method on it.
Example: new EditPopup(myBean).open(); <- EditPopup inherits from Dialog
Closing the dialog is as simple as calling this.close();
Hope this helps :)
I have a delete confirmation dialog in a rapidclipse X application.
Perhaps you can use following example to fullfill your request.
Sorry german dialogs and without deeper explanation:
private void btnDelete_onClick(final ClickEvent<Button> event)
{
final HorizontalLayout horlayout=new HorizontalLayout();
final VerticalLayout vertlayout=new VerticalLayout();
final Notification myDelRequest=new Notification();//
final Button btnAbbr=new Button();
this.logger.info("Der Datensatz mit der ID soll gelöscht werden: " + this.nrDmvId.getValue().toString());
if(this.nrDmvId.getValue() != null && this.nrDmvId.getValue() > 0)
{
btnAbbr.addClickListener(evtclose->
{
this.logger.info("Der Datensatz mit der ID wurde nicht gelöscht: " + this.nrDmvId.getValue().toString());
myDelRequest.close();
});
btnAbbr.setText("Abbrechen");
final Button btnDelConf=new Button();
btnDelConf.addClickListener(evtDelete -> {
try {
if(this.binder.validate().isOk())
{
final boolean confirm = new OkmDbMetadataValueDAO().removeById(this.nrDmvId.getValue().longValue());
this.logger.info("Der Datensatz mit der ID ist gelöscht: " + this.nrDmvId.getValue().toString()+ ", Rückgabe= "+ Boolean.toString(confirm));
this.btnDelete.setVisible(false);
this.btnSave.setVisible(false);
this.fiRegalplatz.setVisible(false);
this.fiposition.setVisible(false);
this.fiKurzBez.setVisible(false);
this.fiBeschreibung.setVisible(false);
this.frmRegale.setVisible(false);
}
}
catch(final Exception e)
{
e.printStackTrace();
}
myDelRequest.close();
});
btnDelConf.setText("Daten löschen");
vertlayout.add(new Label("Wollen Sie den Datensatz wirklich löschen?"));
vertlayout.add(horlayout);
horlayout.add(btnAbbr);
horlayout.add(btnDelConf);
myDelRequest.add(vertlayout);
myDelRequest.setPosition(Position.MIDDLE);
myDelRequest.addThemeVariants(NotificationVariant.LUMO_PRIMARY);
myDelRequest.open();
}
}
Below you will find a second example, which I use to open a dialog with a listbox in it.
After selecting a value out of listbox I transfer and use it in the underlying form:
private void btEditL1_onClick(final ClickEvent<Button> event)
{
//modal Dialog Mainclassification
final HorizontalLayout horlayout=new HorizontalLayout();
final VerticalLayout vertlayout=new VerticalLayout();
final Notification MyL1Selection=new Notification();//
final Button btnAbbruch=new Button();
final ComboBox<TfinGroup> cBL1Liste = new ComboBox<>();
btnAbbruch.setText("Abbruch");
vertlayout.add(new Label("Bitte wählen Sie eine Klasse?"));
horlayout.add(cBL1Liste);
horlayout.add(btnAbbruch);
vertlayout.add(horlayout);
cBL1Liste.setDataProvider(DataProvider.ofCollection(TfinGroupDAO.INSTANCE.findMainGroups()));
cBL1Liste.setItemLabelGenerator(ItemLabelGeneratorFactory
.NonNull(v -> CaptionUtils.resolveCaption(v, "{%id}, {%groupName}")));
cBL1Liste.addValueChangeListener(evtChangeSelektion ->
{
this.logger.info("Es wurde ein Wert aus der Liste selektiert: "+ evtChangeSelektion.getValue().getId());
// muss zu cB2 übergeben werden und in Textfeld nrL1Id
this.nrL1Id.setValue((double)evtChangeSelektion.getValue().getId());
MyL1Selection.close();
});
btnAbbruch.addClickListener(evtclose->
{
this.logger.info("Abbrechen geklickt");
MyL1Selection.close();
});
vertlayout.add(horlayout);
horlayout.add(btnAbbruch);
MyL1Selection.add(vertlayout);
MyL1Selection.setPosition(Position.MIDDLE);
MyL1Selection.addThemeVariants(NotificationVariant.LUMO_PRIMARY);
MyL1Selection.open();
this.btnEditL2.setVisible(true);
}

Call to a member function watermark() in codeigniter

I need to add watermark to the existing image. Codeigniter provides such functionality under image_lib library. Based on the instruction given here , i have done. Fatal error is displaying instead of the result.
A PHP Error was encountered
Severity: Error
Message: Call to a member function watermark() on null
Filename: controllers/Imageman.php
Line Number: 22
Code is
$config['image_library'] = 'gd2';
$config['source_img']='images/images.jpg';
$config['wm_text']='Hi welcome..!';
$config['wm_type']='text';
$config['wm_font_path']='./system/fonts/texb.ttf';
$config['wm_font_size']='16';
$config['wm_font_color']='ffffff';
$config['wm_vrt_alignment']='bottom';
$config['wm_hor_alignment']='center';
$config['wm_padding']='20';
$this->load->library('Image_lib',$config);
$this->Image_lib->watermark();
if($this->Image_lib->watermark())
{
echo "Watermark added";
}
else
{
echo "Failed";
}
After looking at the documentation, it uses:
$config['source_image'] instead of $config['source_img']

SwiftMailer using G Suite Issue

I am trying to setup SwiftMailer on my server. I am using the example configuration from the SwiftMailer docs for testing. I have a paid G Suite account but haven't finished setting up SSL on the server yet. I am running Cent OS 6.8 and Apache 2.2. I have googled everything I can think of and tried all the proposed solutions with no success.
My script is as follows, obviously my email address and credentials are correct in the real script. I appreciate any advice.
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
require_once('swiftmailer-5.x/lib/swift_required.php');
// Create the Transport
$transport = Swift_SmtpTransport::newInstance('smtp-relay.gmail.com', 25)
->setUsername('myemail#mydomain.com')
->setPassword('*****')
;
// Create the Mailer using your created Transport
$mailer = Swift_Mailer::newInstance($transport);
// Create a message
$message = Swift_Message::newInstance('Swift Mailer Test')
->setFrom(array('my from address'))
->setBody('Here is the message itself')
;
// Send the message
$failedRecipients = array();
$numSent = 0;
$to = array('another#email.com' => 'Joe');
foreach ($to as $address => $name)
{
if (is_int($address)) {
$message->setTo($name);
} else {
$message->setTo(array($address => $name));
}
$numSent += $mailer->send($message, $failedRecipients);
}
printf("Sent %d messages\n", $numSent);
?>
When I run this script I get the following very vague error:
"Fatal error: Uncaught exception 'Swift_TransportException' with message 'Connection could not be established with host smtp-relay.gmail.com [Connection timed out #110]' in /var/www/html/appreciate-erp/swiftmailer-5.x/lib/classes/Swift/Transport/StreamBuffer.php:269 Stack trace: #0 /var/www/html/appreciate-erp/swiftmailer-5.x/lib/classes/Swift/Transport/StreamBuffer.php(62): Swift_Transport_StreamBuffer->_establishSocketConnection() #1 /var/www/html/appreciate-erp/swiftmailer-5.x/lib/classes/Swift/Transport/AbstractSmtpTransport.php(113): Swift_Transport_StreamBuffer->initialize(Array) #2 /var/www/html/appreciate-erp/swiftmailer-5.x/lib/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start() #3 /var/www/html/appreciate-erp/mailtest.php(42): Swift_Mailer->send(Object(Swift_Message), Array) #4 {main} thrown in /var/www/html/appreciate-erp/swiftmailer-5.x/lib/classes/Swift/Transport/StreamBuffer.php on line 269"
As of https://support.google.com/a/answer/176600, it seems like SMTP Relay on G-Suite applies IP address restriction. The "could not connect" error would fit as the result of a missing configuration or the attempt to connect from another IP address as the one configured. Hope this helps!

jFile:move does not cause any error while it's failing to move the file

I actually managed to make an installation zip for a plugin that I made and in the installation script file, I included this code in the install function in order to copy some file in a folder within joomla in another directory.
class plgVmCustomPayeddownloadsInstallerScript {
function install($parent) {
$src = "plugins/vmcustom/payeddownloads/payeddownloads.php";
$destination = "components/com_virtuemart/controllers";
if(!JFile::move($src, $destination,JPATH_ROOT)){
echo "tried to move from ".$src." to ".$destination;
return false;
}
}
After the installation I keep getting an error in joomla, "unable to rename the file" and the file that was supposed to be moved commanded by the install function did not, despite the fact that the files within the installation.xml did actually get coppied and installed correctly.
Also within the installation script In the install function I included some sql which is executed normally without any problems.
and I also tried in the postflight function with no success.
Also I do not get any specific erros from the php_error.log
I also tried to create this weird test, with the above tester.php file in my root application of my joomla installation.
<?php
/**
* #package Joomla.Site
* #copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
*/
// Set flag that this is a parent file.
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
if (file_exists(dirname(__FILE__) . '/defines.php')) {
include_once dirname(__FILE__) . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
// Mark afterIntialise in the profiler.
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
// Route the application.
$app->route();
// Mark afterRoute in the profiler.
JDEBUG ? $_PROFILER->mark('afterRoute') : null;
// Dispatch the application.
$app->dispatch();
// Mark afterDispatch in the profiler.
JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
// Render the application.
$app->render();
// Mark afterRender in the profiler.
JDEBUG ? $_PROFILER->mark('afterRender') : null;
//plugins/vmcustom/payeddownloads/payeddownloads.php to
//components/com_virtuemart/controllers
jimport('joomla.filesystem.file');
$src = JPATH_ROOT."/plugins/vmcustom/payeddownloads/payeddownloads.php";
$destination = JPATH_ROOT."/components/com_virtuemart/controllers/";
echo $src."<br>";
echo $destination."<br>";
JFile::move($src,$destination);
?>
The file does not get moved from payeddownloads to controllers folder and it is not causing any error.
Also I need to mention that php.ini has error_reporting = E_ALL and display_errors = On.
Also the php_error.log captures the errors. If I type for example echo "lala"oo it will log the error and it will show it.
So I suspect that JFile::move has a bug and its not throwing any errors even though the file is not copied. Any suggestions please?
Try using the following instead. Few tweaks make to your code:
function install($parent) {
$src = JPATH_SITE . "/plugins/vmcustom/payeddownloads/payeddownloads.php";
$destination = JPATH_SITE . "/components/com_virtuemart/controllers";
if(JFile::exists($src)){
echo "File Exists!";
}
else{
echo "File Doesn't Exist!";
}
if(JFolder::exists($destination)){
echo "Destination Folder Exists!";
}
else{
echo "Destination Folder Doesn't Exist!";
}
JFile::move($src, $destination); // Move file
if(JFile::move($src, $destination)){
echo "File Successfully Moved!";
}
else{
echo "failed to move from ".$src." to ".$destination;
}
}
Even thought the thread is old, I found it having the same issue, maybe the solution could work for anybody else.
JFile::move requires a source and destination FILE path. In the above code the paths should look like follows.
$src = JPATH_SITE . "/plugins/vmcustom/payeddownloads/payeddownloads.php";
$destination = JPATH_SITE . "/components/com_virtuemart/controllers/payeddownloads.php";

Code Igniter - error when trying to config database.php to use PDO driver

I am trying to get the new PDO driver running in Code Igniter 2.1.1 in (to start with) the local (Mac OS 10.7) copy of my app.
I initially coded it using Active Record for all db operations, and I am now thinking I want to use PDO prepared statements in my model files, going forward.
I modified 'application/config/database.php' like so:
(note a couple minor embedded questions)
[snip]
$active_group = 'local_dev';
$active_record = TRUE;//<---BTW, will this need to stay TRUE to make CI sessions work? For better security, don't we want db-based CI sessions to use PDO too?
//http://codeigniter.com/user_guide/database/configuration.html:
//Note: that some CodeIgniter classes such as Sessions require Active Records be enabled to access certain functionality.
//this is the config setting that I am guessing (?) is my main problem:
$db['local_dev']['hostname'] = 'localhost:/tmp/mysql.sock';
// 1.) if $db['local_dev']['dbdriver']='mysql', then here ^^^ 'localhost:/tmp/mysql.sock' works, 2.) but if $db['local_dev']['dbdriver']='pdo', then it fails with error msg. shown below.
$db['local_dev']['username'] = 'root';
$db['local_dev']['password'] = '';
$db['local_dev']['database'] = 'mydbname';
$db['local_dev']['dbdriver'] = 'pdo';
$db['local_dev']['dbprefix'] = '';
$db['local_dev']['pconnect'] = TRUE;
$db['local_dev']['db_debug'] = TRUE;//TRUE
$db['local_dev']['cache_on'] = FALSE;
$db['local_dev']['cachedir'] = '';
$db['local_dev']['char_set'] = 'utf8';
$db['local_dev']['dbcollat'] = 'utf8_general_ci';
$db['local_dev']['swap_pre'] = '';
$db['local_dev']['autoinit'] = TRUE;
$db['local_dev']['stricton'] = FALSE;
[snip]
With the above config., as soon as I load a controller, I get this error message:
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php:114 Stack trace: #0
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php(114): PDO->__construct('localhost:/tmp/...', 'root', '', Array) #1 /Library/WebServer/Documents/system/database/DB_driver.php(115): CI_DB_pdo_driver->db_pconnect() #2
/Library/WebServer/Documents/system/database/DB.php(148): CI_DB_driver->initialize() #3
/Library/WebServer/Documents/system/core/Loader.php(346): DB('', NULL) #4
/Library/WebServer/Documents/system/core/Loader.php(1171): CI_Loader->database() #5
/Library/WebServer/Documents/system/core/Loader.php(152): CI_Loader->_ci_autoloader() #6
/Library/WebServer/Documents/system/core/Con in
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php on line 114
I tried swapping out the 'pdo_driver.php' file from the one on github, as per this:
http://codeigniter.com/forums/viewthread/206124/
...but that just generates other errors, not to mention is disturbing to a newbie who does not want to touch the system files if at all possible.
This thread also seems to imply the need to be hacking the 'pdo_driver.php' system file:
CodeIgniter PDO database driver not working
It seems odd to me, though, that (someone thought that) a hack to a system file is needed to make PDO work in CI v.2.1.1, huh?
Thanks for any suggestions I can try.
I don't know if this might be helpful for you since you already started using the CI functions, but I made my own library for PDO with sqlite and just auto load it. My needs were simple, so it serves its purpose.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter PDO Library
*
*
* #author Michael Cruz
* #version 1.0
*/
class Sqlite_pdo
{
var $DB;
public function connect($path) {
try {
$this->DB = new PDO('sqlite:' . $path);
}
catch(PDOException $e) {
print "Error: " . $e->getMessage();
die();
}
}
public function simple_query($SQL) {
$results = $this->DB->query($SQL)
or die('SQL Error: ' . print_r($this->DB->errorInfo()));
return $results;
}
public function prepared_query($SQL, $bind = array()) {
$q = $this->DB->prepare($SQL)
or die('Prepare Error: ' . print_r($this->DB->errorInfo()));
$q->execute($bind)
or die('Execute Error: ' . print_r($this->DB->errorInfo()));
$q->setFetchMode(PDO::FETCH_BOTH);
return $q;
}
public function my_prepare($SQL) {
$q = $this->DB->prepare($SQL)
or die('Error: ' . print_r($this->DB->errorInfo()));
return $q;
}
public function my_execute($q, $bind) {
$q->execute($bind)
or die('Error: ' . print_r($this->DB->errorInfo()));
$q->setFetchMode(PDO::FETCH_BOTH);
return $q;
}
public function last_insert_id() {
return $this->DB->lastInsertId();
}
}
/* End of file Sqlite_pdo.php */
thanks to the noob thread http://codeigniter.com/forums/viewthread/180277/ (InsiteFX’s answer)..
I figured out the below seems to work (need to test more to be 100%... but at least the error messages are gone:
$db['local_dev']['hostname'] = 'mysql:host=127.0.0.1';

Resources