DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

The Latest Popular Topics

article thumbnail
Is SASE the Solution for Third-Party Risk?
In addition to zero trust, using appropriate tooling like SASE can help secure an organization’s IT infrastructure from threats posed by third-party access.
June 1, 2022
by Gilad David Maayan
· 6,750 Views · 1 Like
article thumbnail
Instrumenting a JavaScript Application for OpenTelemetry, Part 1: Setup
This post looks at the first steps for instrumenting a JavaScript application to report OpenTelemetry metrics.
Updated June 1, 2022
by Chris Ward DZone Core CORE
· 6,263 Views · 1 Like
article thumbnail
Comparing Distributed Databases
What do PostgreSQL, CockroachDB, MongoDB, Redis, and ScyllaDB all have in common? And how do they differ?
Updated June 1, 2022
by Peter Corless
· 11,167 Views · 8 Likes
article thumbnail
Better Scaffolding with jQuery - Part I
Grails scaffolding works great out of the box. Today I want to see how we can improve adding data to the many side of a one-to-many relationship using jQuery, jQueryUI's Dialog, and some Ajax. Using the same domain objects as my previous article I want to show how we can add Reminders to an Event without needing to navigate to a new page, assuming it is ok to create events without reminders. For the sake of clarity, here are the domain objects. class Event { String name static hasMany = [reminders: Reminder] static constraints = { } } class Reminder { ReminderType reminderType Integer duration static belongsTo = [event:Event] static constraints = { } String toString() { "${reminderType} : ${duration}" } } Note that in Reminder I've added a ReminderType. This is a simple Enum with the values Email and SMS. I did this to add a bit of meat to the Reminder form. Once you have a new grails application up and running you'll need to download a couple of things. The first is jQuery. The easiest way to get this in grails is to simply install the plugin. Execute "grails install-plugin jquery" and then in the views/layout/main.gsp modify the g:javascript tag to use "jquery" instead of "application" for the library attribute. We're going to be using jQueryUI's Dialog widget so you'll need to grab a copy of jQueryUI. You can download it from here. The simplest thing is to just include everything and select a theme. Once you extracted the contents of the ZIP file place the jqueryui javascript file in your web-app/js directory and the entire theme folder under web-app/css. Then add the following to your main.gsp: Modify any paths as necessary. Next you'll need to go ahead and create the Event and Reminder domains. Once you've done that we just need the basic scaffolding for all the CRUD. We actually need to generate it (not using def scaffold = true) because we'll need to modify some of the scaffolding code. So execute the following commands: grails generate-all com.package.Event grails generate-all com.package.Reminder Go ahead and run your application and make sure things are working as expected. We're going to focus the next part of our discussion on the edit page for Event. Go ahead and create an event and go to the edit form. It should look like this: If you click Add Reminder right now you are going to be taken to the reminder create screen. What we want to do is change the behavior so that when Add Reminder is clicked a Dialog is shown with the Reminder form in it. Then when we hit a save button, an ajax POST is sent to the server and then we'll use the response to populate the unordered list with the newly created Reminder. First we need a new JavaScript file. I created one called tutorial.js and placed it in web-app/js. Feel free to call it whatever you want. Just make sure you include it in your main.gsp. Next we need to make some modifications to Event's edit.gsp. In this tutorial we are going to hard code the Reminder create form inside the Event's edit.gsp and use jQueryUI's Dialog API to show and hide it when we need it. In a future tutorial I'll show how we can pull the form in via ajax but for now, I want to keep things as simple as possible. Open views/event/edit.gsp and just before the closing body tag, add the following (this is actually just a copy and paste from views/reminder/create, btw): I've wrapped the form inside a div with an id of dialog-form. jQueryUI will use this id for it's selector. Let's go create some javascript. Open up your new javascript file (mine was called tutorial.js) and begin by adding the following skeleton code: $(function() { $('#dialog-form').dialog({ autoOpen: false, height: 300, width: 350, modal: true, buttons: { 'Create a Reminder': function() { }, Cancel: function() { $(this).dialog('close'); } } }); }); If you've used jQuery before this code will look pretty familiar. I'm not going to go into any major details here as it is out of scope for this tutorial. We've created 2 buttons for this dialog. When the 'Create a Reminder' button is clicked, it's callback function is triggered. This is where we'll issue the ajax request to post the form. If the cancel button is triggered, we simply close the dialog. Next, we need to modify the 'Add Reminder' link on the edit page and then add an event handler for it in our javascript so that it displays the Reminder form. Remove or comment out the following line: ${message(code: 'default.add.label', args: [message(code: 'reminder.label', default: 'Reminder')])} And add this in its place: ${message(code: 'default.add.label', args: [message(code: 'reminder.label', default: 'Reminder')])} The reason we didn't just give the g:link tag an id is because it will render the id as the Reminder.id and we simply need it to wire up the event. There are several other options we could have gone with here but this is a simple solution. We now need to wire up the event. I'm showing the full javascript file up to this point with the added code so you can see where it goes: $(function() { $('#dialog-form').dialog({ autoOpen: false, height: 300, width: 350, modal: true, buttons: { 'Create a Reminder': function() { }, Cancel: function() { $(this).dialog('close'); } } }); $('#add_reminder').click(function() { $('#dialog-form').dialog('open'); }); }); Go ahead and try it. Create a new Event and go to it's edit page. Click the Add Reminder and you should see something like this If you click Cancel the dialog should close. If you click Create a Reminder, nothing happens. We still need to add this code. Go back to your javascript file and let's fill out the Create a Reminder callback function. Again, I've included the entire javascript file and then I'll talk about the added code. $(function() { $('#dialog-form').dialog({ autoOpen: false, height: 300, width: 350, modal: true, buttons: { 'Create a Reminder': function() { var duration = $("#duration").val(); var reminderType = $("#reminderType option:selected").val(); var event = $("#id").val(); $.post(contextPath + '/reminder/save', {'event.id':event, duration:duration, reminderType:reminderType}, function(data) { }, 'json'); $(this).dialog('close'); }, Cancel: function() { $(this).dialog('close'); } }, close: function() { } }); $('#add_reminder').click(function() { $('#dialog-form').dialog('open'); }); }); The first thing we do is we get the form parameters we want to pass back to the server. So we need the duration value, the reminderType value, and we need to pass back the event id so that the new reminder is added to the correct event. Note that the event.id is simply a hidden field on the edit form. Then we issue the $.post() to the server giving it the URL, our parameters, and we define a callback function. I've also defined the response type as json. This will be explained in a bit. We need to do something with the response but first we need to modify our ReminderController's save method to render json instead of the typical redirect that normally would happen. Open ReminderController and replace the following code: flash.message = "${message(code: 'default.created.message', args: [message(code: 'reminder.label', default: 'Reminder'), reminderInstance.id])}" redirect(action: "show", id: reminderInstance.id) with this code: render reminderInstance as JSON Just for clarity here is the entire save method from ReminderController.groovy. def save = { def reminderInstance = new Reminder(params) if (reminderInstance.save(flush: true)) { render reminderInstance as JSON } else { render(view: "create", model: [reminderInstance: reminderInstance]) } } Make sure you add the import statement for JSON if not using an IDE that reminds you to do so. We save the new reminder and we return the reminder as json. This is great because we need to add a new list item to the unordered list on the event's edit page, just as it does when edting an event with existing reminders. Here comes more javascript, again, the entire file and then I'll explain the new code: $(function() { $('#dialog-form').dialog({ autoOpen: false, height: 300, width: 350, modal: true, buttons: { 'Create a Reminder': function() { var duration = $("#duration").val(); var reminderType = $("#reminderType option:selected").val(); var event = $("#id").val(); $.post(contextPath + '/reminder/save', {'event.id':event, duration:duration, reminderType:reminderType}, function(data) { var item = $(""); var link = $("").attr("href", contextPath + "/reminder/show/" + data.id).html(data.reminderType.name + " : " + data.duration); item.append(link); $('#reminder_list').append(item); }, 'json'); $(this).dialog('close'); }, Cancel: function() { $(this).dialog('close'); } } }); $('#add_reminder').click(function() { $('#dialog-form').dialog('open'); }); }); The newly added code here is the callback for $.post(). First we create a new LI element. Then we create a new anchor element and add the href attribute. Notice how when we need the reminder properties, since it is a json object, we can just reference the properties directly. The HTML of the anchor tag mimicks what is done in the toString method of Reminder. That way, when we come back to this page with existing reminders, and add new ones, they appear the same way. The last thing you need to do is add an id of "reminder_list" to the UL on th edit page so that we can append the item to it. And that's it. In the next article I'll show how we deal with validation errors when saving a Reminder who's constraints fail.
May 26, 2022
by Gregg Bolinger
· 37,079 Views · 1 Like
article thumbnail
AWS Lambda With MySQL (RDS) and API Gateway
In this article, we discuss the limitations of Lambda and how to design simple micro-service using AWS API gateway, and RDS.
Updated May 26, 2022
by Viquar Khan
· 47,816 Views · 9 Likes
article thumbnail
Autoscaling Your Kubernetes Microservice with KEDA
Introduction to KEDA—event-driven autoscaler for Kubernetes, Apache Camel, and ActiveMQ Artimis—and how to use it to scale a Java microservice on Kubernetes.
Updated May 26, 2022
by Tom Donohue
· 14,860 Views · 6 Likes
article thumbnail
Authentication and Authorization: Mastering Security
Your one-stop-shop for all things authentication and authorization.
Updated May 26, 2022
by Peter Connelly
· 30,378 Views · 18 Likes
article thumbnail
Storeon: An Event-Based State Manager for Velo
In this article, we explain how to manag state in Velo with a light-weight and robust solution: Storeon, an event-based state manager.
Updated May 26, 2022
by Alexander Zaytsev
· 10,276 Views · 4 Likes
article thumbnail
Are You Getting What You Need from Your UI Testing Tool?
The UI testing tool you have should check all the boxes for your business requirements.
Updated May 26, 2022
by Chris Colosimo
· 4,481 Views · 2 Likes
article thumbnail
Apache Harmony Finally Defeated
Some have probably been expecting it for a long time, and this week it finally happened. Apache Harmony, an open source cleanroom implementation of Java was moved to the Apache Attic, where inactive projects are sent. The project management committee voted 20 to 2 in favor of discontinuing the project. One of the votes against moving Harmony to the Attic was PMC chair Tim Ellison, who thought it was too early to deactivate Harmony. But Harmony was probably already dead and buried once it's primary corporate sponsor, IBM, switched its support to OpenJDK last year. Android has not gotten invovled in the Harmony project recently because of their ongoing lawsuit with Oracle. Developers may still use the code while it resides, inactive, in the Apache Attic. Here were some comments from last year when most predicted the death of Harmony: "Well, pragmatically I would prefer one great open source JVM, rather than multiple average ones. So as long as OpenJDK is still GPL, I see no reason to cry over this. Reality is that I don't know of a single project going into production using Harmony. " --Jacek Furmankiewicz "Google has single handedly turned around the disaster that was J2ME. Assuming they'll eventually sort out the patent mess (and given the stakes, they will) that removes from the equation all the partners that had very little to bring to the table when it comes to mobile Java. Meanwhile, Oracle and IBM need to demonstrate through actual technical innovation that they are still relevant in the Java world. Last time I checked, the enterprise Java world was dominated by things like Spring (under the Apache license) rather than any JCP efforts. Oracle bought an empty shell. Filing patent related lawsuits left and right is probably not going to be very helpful since that tends to scare away customers. So, I'm hoping that this will end pretty quickly. Once it does, all parties can get back to moving the agenda forward on the run-time, language, and APIs. There is a lot of stuff that needs to start happening there and if Oracle won't do it, others will do it for them. In a nutshell, that's why Google is shipping Harmony rather than CDC. I'm pretty sure Google would have preferred to stay in the Sun community a few years ago if only Sun was not being so unreasonable." --Jilles van Gurp "For me, the question is: what to we, as coder, expect from Java? I don't think I will ever use a self patched SDK/openSDK in any production; I even doubt I would ever work in a project which would like todo that. Oracle might be the bad boy here, but -man!- they know techology. I strongly believe, that the SDK will be less stagnant in performance/features and lots of those 10 year old problems in Bugzilla will finally be tackled. Sun let the "open" part of Java start smelling and people started to invest significant time in non-Java languages like Scala and new ways of dealing with partitioning of services aka OSGi containers. Since JVM 1.5 they were not really able to focus this community power to anything bigger then some lame syntactic sugar and a DOA flash clone. Harmony is a nice place to play around with an open JVM, but I think this job moves more over to the more general LLVM. And I don't think that I want to bet my (professional) future on the fact that Google has to step always in when the rest of the industry has just a bad haircut day. IBMs move is logical. Whatever Harmony is or was, the impact was already limited. You simply can't build such infrastructure without more people building it. One company alone wouldn't push Apache or Tomcat, and any serious openJDK shouldn't do either." --Igor Laera Let the conversation now continue.
May 26, 2022
by Mitch Pronschinske
· 25,912 Views · 3 Likes
article thumbnail
Apache Aries: Helping Enterprise Developers Build OSGi Apps
the approval of the blueprint container specification by the osgi alliance enterprise expert group (eeg) inspired members of the eeg to start an open source project centered around implementing the blueprint spec and other technologies for osgi applications. in september the apache aries project was born in the apache incubator. the purpose of the apache aries incubator is to create a new community of people interested in building enterprise osgi technology geared toward the application programming model. for an introduction to the history and the purpose of the aries project, dzone interviewed ian robinson, a distinguished websphere engineer and a member of the osgi eeg. robinson is at the frontrunner for the apache aries project and has begun using its technology for ibm's websphere application server. dzone asked robinson about the factors inspired the aries project. robinson said, "from a standards direction, the work of the osgi alliance eeg was to define a set of specifications that would form part of an enterprise profile for osgi." he says the eeg has approved several specs for technologies that allow osgi applications to consume existing java ee technologies like jta, jpa, jndi, etc. "the purpose of the eeg was not to try and define competing specifications but to take what exists already in the java enterprise space and define how those technologies become consumable for applications running in an osgi framework," robinson said. robinson also observed some point efforts starting up inside existing apache projects that didn't have an enterprise osgi home to host them. one example was an implementation of the blueprint container spec, which started out inside apache geronimo , an open source java ee application server. robinson said that developing a blueprint implementation in geronimo made sense since the app server could use the it, but that didn't provide much visibility of the blueprint work outside of the geronimo project. robinson and his collaborators thought it would be a better idea to start a new incubator project who's primary focus was enterprise osgi, form a community around it, and then gather a set of osgi technologies in that new project so that other projects like geronimo, felix karaf, and servicemix could use that technology in their own runtime environments. apache aries is not an effort to build a new enterprise application server or a new application integration runtime. robinson says the purpose of the project is to build components like the blueprint container that can be used by those enterprise application servers. apache geronimo is currently working on consuming the aries blueprint container and apache felix karaf , which is the kernel of an enterprise integration runtime, is already consuming the aries blueprint container. in its three month existence, the apache aries incubator has already been successful in building a sizable community. including robinson, there are currently 43 committers distributed across a wide variety of companies. robinson says at the end of an incubation period, an incubator is considered a success and a top level project if it builds a vibrant community, and aries is well on its way with companies like red hat, progress, ibm, and sap represented. right now, no timeframe has been determined for when the aries project intends to graduate from incubation. robinson says the community will decide when they've done enough work to become a top level project. dzone asked robinson the most important question for any apache project: 'how did the project get its name?' robinson explains: "we started thinking in ibm about the aries project way back in early april when the blueprint work started in apache geronimo. i mentioned that geronimo is a consumer of blueprint, but not the obvious project to develop it - we thought back then that what we needed was a new incubator for the blueprint container and other enterprise osgi technologies. aries is the star sign for that time of the year - simple as that." hence the logo for apache aries is the ram. ibm's websphere application server v7 already uses some of the technology in the apache aries project for its open alpha , which helps deploy enterprise applications as osgi bundles. to get involved with the apache aries project, you can visit their "getting inolved" page.
May 26, 2022
by Mitch Pronschinske
· 23,353 Views · 3 Likes
article thumbnail
Android Tutorial – Learn Android From Scratch!
In this article, we discuss the basics behind Android app development, including architecture, application anatomy, and a quick "Hello, World"app.
Updated May 26, 2022
by Aayushi Johari
· 17,959 Views · 8 Likes
article thumbnail
Get Started With Cloud-Native Decision Automation on Quarkus
Learn how to automate decisions using Quarkus and Kogito.
Updated May 26, 2022
by Karina Varela
· 7,181 Views · 2 Likes
article thumbnail
The Definitive Guide to Building a Data Mesh With Event Streams
The data mesh concept is often presented with scant details regarding an implementation. We have created an opinionated prototype showcasing the principles of data mesh.
May 26, 2022
by Adam Bellemare
· 9,187 Views · 2 Likes
article thumbnail
Dockerizing Your Node.js Application
Learn about Dockerizing your Node application in this short but sweet step-by-step tutorial with code blocks.
May 26, 2022
by Pavan Belagatti DZone Core CORE
· 7,552 Views · 1 Like
article thumbnail
Top 7 Automated Testing Trends of 2022
Test automation has never been a stagnant category: continuous innovation, rapid growth, and broader acceptance is all baked in. But 2022 is a special year.
May 25, 2022
by Niranjan Limbachiya
· 9,680 Views · 1 Like
article thumbnail
Python: A Befitting Approach to Develop AI Web Apps
Before digging into the roots of why to develop AI web apps in Python, let’s discover the basics, including meaning, facts, and figures of Artificial Intelligence.
May 25, 2022
by Harshita Agnihotri
· 6,333 Views · 2 Likes
article thumbnail
Basic Convolutional Neural Network Architectures
This article reviews some ways that CNN architectures differ, including how the layers are structured, the elements used in each layer, and how they are designed.
Updated May 25, 2022
by Anomi Ragendran
· 8,112 Views · 2 Likes
article thumbnail
Growth in Java Development for Web and Mobile Apps
Java development services have been in use for over 15 years now. Here’s what you need to know about the growth of Java web and mobile application development.
Updated May 25, 2022
by Parth Barot
· 5,692 Views · 2 Likes
article thumbnail
Experience Obsolesce: The Glaring Reality of Rapid Technology Change
There is a growing phenomenon in the IT community that challenges the concept of experience and a lifelong dedication to a career or area of study.
May 24, 2022
by Kartik Patel
· 4,336 Views · 1 Like
  • Previous
  • ...
  • 271
  • 272
  • 273
  • 274
  • 275
  • 276
  • 277
  • 278
  • 279
  • 280
  • ...
  • Next
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook
×