Gregory's Blog

ColdFusion ORM Error - java.lang.Integer, etc.


Coldfusion orm java.lang.Int error

Background I ran into an interesting error when working on converting Galaxie Blog's database to use ORM. When importing data from the original database, I received a very cryptic ColdFusion ORM error coldfusion orm java.lang.String errorerror when trying to set the value of a foreign key. It was trying to set an int, and assumed that ColdFusion somehow was casting the int to a string. I manually set the value to an int, and still received the error, but this time received Coldfusion orm java.lang.Int error. This was perplexing. This should have worked as the foreign key expected an int.

Relevant property of BlogRef

<cfcomponent displayName="Users" persistent="true" table="Users" output="no" hint="ORM logic for the new Users table">
<cfproperty name="UserId" fieldtype="id" generator="native" setter="false">
<!-- Many users per blog. --->
<cfproperty name="BlogRef" ormtype="int" fieldtype="many-to-one" cfc="Blog" fkcolumn="BlogRef">
</cfcomponent>

To try to understand what was going on- I kept on trying to change the datatype, but no matter what I set the datatype to, I would receive the same cryptic error. The only difference in the error is that the datatype java.lang.thisDataType errorwould change.

Even hardcoding the value to an int causes an error:

<!-- Load the entity. --->
<cfset UserDbObj="entityNew("Users")">
<!-- Use the entity objects to set the data. --->
<cfset UserDbObj.setBlogRef(1)="">

Results in: Coldfusion orm java.lang.Int error What was even more perplexing is that I had successfully used the same code in previous blocks that had worked! I have just started down the ColdFusion ORM path and wondered what the hell have I gotten myself into. After much research, it turns out that either ColdFusion ORM or Hibernate wants an object passed to a foreign key. Oftentimes, ColdFusion may always raise this cryptic error if the value is set in any other way! The following code finally solved this perplexing error:

<!-- Load the blog table and get the first record (at this time there only should be one record). This will pass back an object with the value of the blogId. This is needed as the setBlogRef is a foreign key and for some odd reason ColdFusion or Hibernate must have an object passed as a reference instead of a hardcoded value. --->
<cfset BlogRefObj="entityLoadByPK("Blog"," 1)="">
<!-- Load the entity. --->
<cfset UserDbObj="entityNew("Users")">
<!-- Use the BlogRefObj entity object to set the data. --->
<cfset UserDbObj.setBlogRef(="" BlogRefObj="" )="">

Further Reading How do I store an integer using ColdFusion Orm? - by James Cushing

This entry was posted on November 28, 2019 at 12:30 PM and has received 978 views.

ColdFusion Orm, a fantastic book by John Whish


ColdFusion ORM, a fantastic book by John Whish

Background

I needed to learn ColdFusion ORM as ORM supports all of the modern databases that want Galaxie Blog to be able to support. I don't want to have to incorporate different SQL logic for every database. Coding everything by hand would be an immense task, and would be problematic to test. Using ColdFusion ORM would solve this dilemma and I could use a single codebase that would automatically translate the ORM logic across various database platforms. However, learning anything new that has such a large scope is a daunting task.

Enter John Whish's ColdFusion ORM book to the rescue!

In order to embark on my re-coding effort, I ordered and read a ColdFusion ORM book written by John Whish and found his book to be an invaluable resource. The book is concise and well laid out. It starts by answering simple questions, such as What is ORM? and provides a general background. His book shows you how to configure ORM, explains that ORM is used for CRUD operations, and then gets into the meaty topics such as ORM relationships and HQL. In the final part of the book John discusses validation, caching and provides helpful tips.

If you're using ORM and ColdFusion, I found his book to be an invaluable resource.

Related Resources

This entry was posted on November 22, 2019 at 1:44 PM and has received 1208 views.

Plyr Themes now match Galaxie Blog's Kendo UI themes


How to modify the Plyr theme

If you're a Galaxie Blog owner, you can change the primary colors of the Plyr controls. The Plyr media player is now themed for Galaxie Blog's themes, but for those who are running Galaxie Blog, you can further modify the Plyr themes by simply changing the .css in the common/libs/plyr/customThemes folder to match your own created theme.

Simply open the plyr.css file in the common/libs/plyr/ folder, and search and replace both the RGB and Hexadecimal values.

The default Plyr .css file specifies a RGB value of 0,179,255, and the hexadecimal value is #00b3ff. There are 5 occurences of both 0,179,255 and 00b3ff.

Plyr Themes now match Galaxie Blog's Kendo UI themes

Kendo UI already has a built in media player, but it is only available if you have a commercial licsense. Telerik did not put its own media player into its open source distribution of Kendo Core. However, even if you have a license, I recommend using Plyr. The Pylr media player is far superior, and offers much more functionality, such as supporting captions, add revenue capabilities, and even has air-play support. It also supports Vimeo and YouTube.

I am ditching Kendo's media player and have modified Plyr to support the Kendo default less based themes. All that you need to do is incorporate the proper theme css file in the header after initializing the Plyr.

Getting the new Kendo UI Plyr Themes

I have created a fork and saved my own Plyr GIT repository at https://github.com/GregoryAlexander77/plyr/tree/master/themeCss. There is one .css file for every Kendo UI less based theme.

Happy theme... err, streaming!

This entry was posted on November 19, 2019 at 8:07 PM and has received 696 views.

Sharing Video's to Facebook and Twitter

How to share videos on Facebook and Twitter from your own website

Note: if you're using Galaxie Blog, all that you need to do is upload your file and create the necessary XML Post Directives and Galaxie Blog will take care of the rest for you. This post is a technical how-to article on how I incorporated Plyr into Galaxie Blog. This is a continuation of my how to make the perfect social media sharing image series, but here we focus on using video and audio on Facebook and Twitter instead of sharing images.

Create the Video

In this video, I used a Battlestar Galactica preview made as a university project made by Bob. The 2004 Battlestar Galactica was one of my favorite Sci-Fi TV shows. The 2004 version of Battlestar Galactica is essentially a science fiction rendition of both the Genesis and Exodus stories, but the 10 plagues were instead caused by 6 different eerily human-like robots created by humans. OK, enough of the Sci-Fi stuff; time to get back to the substance of this article here.... Your own video should be created in mp4 format using the progressive HDTV 720p format. The final size should be 1280 x 720 (2048K bitrate).

Creating the images used by the social media platform along with the cover image

We still need to create several images to serve as the cover image. These images will cover the video until the video is loaded. If you reload this page, you will see a dark Battlestar Galacticaimage that will cover the video until the video is loaded. Once the video is loaded, the large arrow will show on top of the cover image.

  1. After you have created the video, create an image of the video by pressing the print screen. We will use this to create the images that we'll use in the image meta tags and to create a cover image for the video
  2. Crop the images using the same ratio and size formats as we did in part 2. The cover image for Facebook should be 1200x630, Twitter's dimensions are nearly the same at 1200x628. The cover image should be either .jpg or .png. WebP is not yet supported for social media sharing. I am providing resources and examples below.
  3. Once you have created and uploaded the images to your site, we need to create the essential open graph and Twitter tags and validate them on our web page as we did here:

You'll need to have an HTML5 capable Media Player on your website

It goes without saying that you'll also need to have an HTML5 Media Player to handle the video and audio formats on your own website. If you don't have an HTML5 media player, you can follow my steps to integrate Plyr on your own website.

Creating a separate player instance for Twitter

Unfortunately, Twitter can't read embedded videos from your own web page. Buried in Twitters player card documentation, you'll find that you also need to create a separate instance of your media player, and either point to the new instance, or an iframe. Importantly, the video must take up the full width of the page. This is how I solved this issue using Plyr. If you don't have Plyr, you'll have to use this approach with your own HTML5 media player. Here is the ColdFusion code that I used to create a new page with Plyr.

<!doctype html>
<!--- Note: this is a proof of concept page. This template will be revised. --->
<head>
	<!-- Plyr (our HTML5 media player) -->
	<InvalidTag src="/blog/common/libs/plyr/plyr.js"></script>
	<!-- Plyr css. -->
	<link rel="stylesheet" href="/blog/common/libs/plyr/plyr.css" />
</head>

<cfparam name="URL.videoUrl" default="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4">
<cfparam name="URL.poster" default="https://gregoryalexander.com/blog/enclosures/twitter/blueMoonTrailer.jpg">
<cfparam name="URL.crossOrigin" default="false">
<style>
<!--- This must be set to full screen! --->
.mediaPlayer video {
	width: 100% !important
}
</style>

<div class="mediaPlayer">
	<video
		controls
		<cfif URL.crossOrigin eq true>crossorigin</cfif>
		playsinline
		poster="<cfoutput>#URL.poster#</cfoutput>"
		id="player1">
		<!-- Video files -->
		<!-- 1280x720 --->
		<source
			src="<cfoutput>#URL.videoUrl#?id=#createUuid()#</cfoutput>"
			type="video/mp4"
			size="720"
		/>

	</video>
</div>

This new instance of your player must be set to take the full width of the page. If it does not render the video using the full width of the page, Twitter will play the video at a much smaller resolution and the users will only see part of the video being played.

Creating the essential media meta tags

Twitter tagsThe following twitter tags must be set in the header of the page.

  • The first tag, the twitter:player meta tag is a directive that tells Twitter that we want to use the player card. When we are using just an image and not a video, we would use 'twitter:card' 'summary_large_image'
  • The next 4 tags are similar, if not identical, to the tags that we've covered in How to make the perfect social media sharing image - part 5. The only difference is that here we are using the image of the video that you have created in a previous step above.
  • I am using ColdFusion's createUuid function to generate the id element in the twitter:image. This is a trick that I learned to refresh the twitter preview after the initial twitter preview has been made.
<!-- Twitter meta tags. -->	
<!-- Note: we are using the twitter player card --->		
<script name="twitter:card" content="player" />
<script name="twitter:site" content="@https://gregoryalexander.com/blog" />
<script name="twitter:title" content="Plyr, a HTML5 media player, is incorporated into Galaxie Blog" />
<script name="twitter:description" content="Plyr is now the default HTML5 media player in Galaxie Blog" />
<!-- This is a picture taken of the video. The size of this image is 1200x628. --->
<script name="twitter:image" content="https://gregoryalexander.com/blog/enclosures/twitter/blueMoonTrailer.jpg?id=E2DC9DE6-9B6A-9736-EE1FFFD42B90FEC3" /> 

The next tags are used to tell Twitter how to play our fancy shiny video.

  • The "twitter:player" tag has the full URL to the minimal HTML5 Media Player that we covered above
  • The "twitter:player:width" for the recommended 720p video is 1280 pixels.
  • And the "twitter:player:height" for the recommended 720p video is 720 pixels.
<!-- Twitter player card meta types -->
<!-- The twitter video must be on a minimal page that just includes the video, and nothing else. -->
	
<script property="twitter:player" content="https://gregoryalexander.com/blog/videoPlayer.cfm?videoUrl=https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4&poster=https://gregoryalexander.com/blog/enclosures/twitter/blueMoonTrailer.jpg&id=E2DC9DE7-9749-288C-C9BA9EBE432D3203">
<script property="twitter:player:width" content="1280"></script>
<script property="twitter:player:height" content="720"></script>

Facebook Open Graph Tags

Facebooks' approach to video sharing is more streamlined than Twitter's. First, we don't need a minimal media player that plays the video on a full page. Facebook will glean the source of the video found in the og:video tag. The first 5 tags are identical to the open graph meta tags used for images. The only difference is that I added an extra fb:app_id meta tag. This key is not required; I am using my own developer key here as I want Facebook to know that this share is coming from a trusted source.

<!-- Open graph meta tags for Facebook. See notes. -->
<script property="og:image" content="https://gregoryalexander.com/blog/enclosures/facebook/blueMoonTrailer.jpg" /> 
<script property="og:site_name" content="Gregory's Blog" />
<script property="og:url" content="https://gregoryalexander.com/blog/2019/11/15/Plyr-a-HTML5-media-player-is-incorporated-into-Galaxie-Blog" />
<script property="og:title" content="Plyr, a HTML5 media player, is incorporated into Galaxie Blog" />
<script property="og:description" content="Plyr is now the default HTML5 media player in Galaxie Blog" />
<script property="fb:app_id" content="your facebook app id" />

The next set of tags informs Facebook that we are sharing a video.

  • The og:type tag indicates that we are using video.
  • The og:video:type tag indicates that we are using .mp4 as our video format. Facebook recommends .mp4 as its preferred video format.
  • The og:video, og:video:url, and og:video:secure_url should point to the same URL that is the source of the video. The video:type is not required, but I am including it in my code just to cover all of my bases here.
  • The og:video:width and height tags use the same width and height as Twitter using the 720p video format.
<!-- Video meta types -->
<script property="og:type" content="video.movie" />
<script property="og:video:type" content="video/mp4" />
<script property="og:video" content="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4" />
<script property="og:video:url" content="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4" />
<script property="og:video:secure_url" content="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4" /> 
<script property="og:video:width" content="1280" /> 
<script property="og:video:height" content="720" /> 

You can see an example of how this video was shared by following me on Twitter. Happy coding!

This entry was posted on November 18, 2019 at 2:00 PM and has received 991 views.

Integrating a HTML5 Media Player using Plyr


Integrating Plyr into your own website

Note: if you're using Galaxie Blog, all that you need to do is upload your video and create the necessary XML Post Directives and Galaxie Blog will take care of the rest for you. This post is a technical how to article how I incorporated Plyr into Galaxie Blog.

Background

I needed to integrate a new HTML5 Media Player into Galaxie Blog for several reasons. I was using the Kendo UI HTML5 Media Player as it was integrated with the themes that I developed for Galaxie Blog, however, it is not part of the Kendo Core open source distribution, and required other Galaxie Blog owners to have a Kendo UI license. It was my goal to integrate a new HTML player that was open source. I had thought to use Kendo's media player if the blog owner had a license, however, after integrating Plyr, I determined that Plyr offers quite a bit more functionality than the Kendo Media Player, and changed the default media player to Plyr- even if the blog owner had their own Kendo commercial license.

Why Plyr?

Plyr is a simple, lightweight, accessible and customizable HTML5 media and audio player. It supports HTML Video, Audio, YouTube and Vimeo. It has support for video captions in multiple languages, and has add revenue capabilities. What also excited me is that I could cast my videos to my own TV. Plyr also supports air play, and I wanted to be able to view the video's that I took on my own TV.

How to integrate Plyr into your own website or blog

Integrating Plyr is relatively trivial. I will show you the steps that I used to integrate Plyr into Galaxie Blog. This is meant as a general how to document, if you run into problems or want more information, see the full documentation on the Plyr GitHub site

  1. Clone or download Plyr at https://github.com/sampotts/plyr
  2. Upload all of the files found in the dist folder to your own site

Once the files have been uploaded, you will need to open the index document of your site and edit a few lines of code Load the javascript and css files in the head portion of your document like so:

<head>
	<!-- Plyr (our HTML5 media player) -->
	<script src="/blog/common/libs/plyr/plyr.js">
	<!-- Defer the plyr css. -->
	<link rel="stylesheet" href="/blog/common/libs/plyr/plyr.css" />
 	</script >
</head>

Find the portion of the page where you would like the video to be displayed, and copy and paste the code below into your own webpage. Pay attention to the crossorigin argument. You need to remove the crossorigin argument if your video is hosted on your own site. If the video is hosted elsewhere, such as the plyr cdn site, you'll need to put the crossorigin argument back into the code. If you have different sized videos, let's say one with 720p and 1080p, put both of the sources in there. The Plyr library will dynamically choose the most appropriate video size that can be rendered on your site. Of course, you can also put in one video source. Video captions are supported and are optional.

<div id="mediaplayer" class="mediaPlayer">
 	<video controls="" crossorigin="" playsinline="" poster="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.jpg" id="player1" class="lazy">
		<!-- Video files -->	
		<source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-720p.mp4" type="video/mp4" size="720" />
		<source src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-1080p.mp4" type="video/mp4" size="1080" />
		<!-- Caption files -->
		<track kind="captions" label="English" srclang="en" src="https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt" default="" />
 	</video>
</div>

Finally, put the following script at the very end of your code. You need to do this if you need to have more than one video on your page. If you only have one video on your page, the script will not cause any errors, so I advise you to put this at the end of your page.

<script type="deferjs">

	// Initialize the plyr.
	const players = Plyr.setup('video', { captions: { active: true } });
	// Expose player so it can be used from the console
	window.players = players;
</script>

This article was meant to quickly convey how to put a basic Plyr Media Player on your own web page. You'll definitely want to check out the Plyr GitHub website for more information. If you want to see how the video looks on Galaxie Blog, see Plyr, a HTML5 media player, is incorporated into Galaxie Blog In our next article, we'll see how we can share our video to both Facebook and Twitter Thanks for reading!

This entry was posted on November 17, 2019 at 4:47 PM and has received 4067 views.




Footer Logo

Your input and contributions are welcomed!

If you have an idea, BlogCfc based code, or a theme that you have built using this site that you want to share, please contribute by making a post here or share it by contacting us! This community can only thrive if we continue to work together.

Images and Photography:

Gregory Alexander either owns the copyright, or has the rights to use, all images and photographs on the site. If an image is not part of the "Galaxie Blog" open sourced distribution package, and instead is part of a personal blog post or a comment, please contact us and the author of the post or comment to obtain permission if you would like to use a personal image or photograph found on this site.

Credits:

Portions of Galaxie Blog are powered on the server side by BlogCfc, an open source blog developed by Raymond Camden. Revitalizing BlogCfc was a part of my orginal inspiration that prompted me to design this site.

Version:

Galaxie Blog Version 3.0 (Toby's Edition) June 14th 2022 Abstract Blue theme