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 Frameworks Topics

article thumbnail
Which One Is Better: Kotlin vs Flutter?
Do you have any doubts regarding which tech stack to use? Learn more about Flutter vs. Kotlin in our comparison.
June 7, 2022
by Martin K.
· 6,513 Views · 2 Likes
article thumbnail
Developing TPU Based AI Solutions Using TensorFlow Lite
Edge TPU combined with the TensorFlow Lite framework opens several edges AI applications opportunities.
Updated June 7, 2022
by Rakesh Nakod
· 6,230 Views · 1 Like
article thumbnail
Selenium vs. Protractor: What's the Difference?
As software testers, we should be aware of these 2 phrases, Selenium and Protractor. We will see the difference between selenium and protractor.
Updated June 6, 2022
by Pallavi Singh
· 6,497 Views · 4 Likes
article thumbnail
URL Shortener Complete Tutorial
This article goes in-depth about how to create an URL shortener with Java and Spring Boot, which you can use for your project portfolio or interview practice.
Updated May 27, 2022
by Ante Marin
· 24,668 Views · 20 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
· 36,941 Views · 1 Like
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,810 Views · 6 Likes
article thumbnail
Automatic Reference Counting (ARC) and Memory Management in Swift
Manage your memory better with ARM and Swift.
Updated May 26, 2022
by Prashant Sharma
· 10,499 Views · 2 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,299 Views · 18 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,452 Views · 2 Likes
article thumbnail
A Complete Guide About Scaled Agile Framework (SAFe)?
Scaled Agile Framework: Get your hands on detailed insight into the leading Scaled Agile Framework for business agility - SAFe.
May 25, 2022
by Arvind Sarin
· 5,353 Views · 2 Likes
article thumbnail
A Guide to Test Automation Types, Tools, and Benefits
Why should you have to do all that heavy testing lifting by yourself? Or at all?
Updated May 19, 2022
by Praveen Mishra
· 41,162 Views · 23 Likes
article thumbnail
Creating a Spring Boot Project With Eclipse and Maven
In this article, we look at three options for creating Spring Boot projects with Maven and Eclipse: using Spring Initializr, using the STS plugin, and doing it manually.
Updated May 18, 2022
by Ranga Karanam
· 484,520 Views · 19 Likes
article thumbnail
Creating a REST Web Service With Java and Spring (Part 1)
In the first part of this series, we take a look at how the design of the web service we'll be creating, and the tech we'll be using to there.
Updated May 17, 2022
by Justin Albano DZone Core CORE
· 441,508 Views · 78 Likes
article thumbnail
Autowiring in Spring
Spring can automatically detect the relationships between various beans. Learn how to do this using the XML-based autowiring functionality.
Updated May 16, 2022
by John Thompson
· 221,613 Views · 54 Likes
article thumbnail
Building a Login Screen With React and Bootstrap
We will build an elegant login screen super fast using React and Bootstrap 5.
May 16, 2022
by Advait Ruia
· 6,165 Views · 1 Like
article thumbnail
Suspicious Sortings in Unity, ASP.NET Core, and More
Time to review sorts and how devs can botch them.
May 13, 2022
by Sergey Vasiliev
· 6,138 Views · 5 Likes
article thumbnail
Image Classification Using SingleStore DB, Keras, and Tensorflow
Follow along in this tutorial to learn how to store Fashion MNIST images and ML predictions in SingleStore DB.
Updated May 13, 2022
by Akmal Chaudhri DZone Core CORE
· 7,716 Views · 3 Likes
article thumbnail
Flutter vs React Native. How to Cover All Mobile Platforms in 2022 With No Hassle
In this article, we will compare Flutter and React Native to decide which framework to choose for mobile app development.
May 13, 2022
by Sergey Laptick
· 5,958 Views · 2 Likes
article thumbnail
Exporting and Importing Projects in Eclipse
I admit that I have (a few? or not so few) bad habits: one of them is that usually, I find a way to do things, and if that works, I stick with it. I know that there are other ways to do things, but hey, why bother? and sometimes a good friend asks an excellent question (are there any bad questions?), and this lets me review the way I’m doing things. and here is such a thing: exporting and importing projects in eclipse. Archive Files With Drag & Drop Here is how I usually move or copy a project to another machine: Find the project place on my hard disk. an easy way is to select the project folder and use the context menu with show in windows explorer Zip that projects into an archive file Delete from that archive file any derived resources (see dissection of mcu10 projects ), as well as remove all the version control information. Copy the archive file into the destination workspace and unzip it there Then drag&drop that folder into eclipse: this will import that project into the workspace. Instead of the folder I simply can drag&drop as well the .project file note: best if i drag&drop the project into the ‘codewarrior projects’ view. this will not work if i drop it into the processor expert ‘project panel’ view. well, that works, and I really get used to that process. so why bother? because there is actually a better way: to export and import. The Export and Import Way 1. Select one or more project and use the ‘export’ context menu or file > export. Here select general > archive file: export project as archive file 2. In the ext dialog, you can deselect files and folder. additionally, you need to specify the archive file. You could use filter types (e.g. to include *.c and *.h). I really wish that this dialog would consider the ‘derived’ flags for files and folder, so I could deselect them easier. archive file settings 3. In the destination workspace, use the menu file > import : import dialog to import a project and here is the stumbling point: Do not (!) select ‘archive file’, but ‘ existing projects into workspace ‘. I have exported it as archive file, but importing an archive file is importing an archive file inside a project , not (!) as a project . This is a usability quirk in eclipse. 4. In the next dialog, you can choose the archive file and make adjustments which project you want to import. Note that it will automatically copy the projects into my workspace. import archive projects 5. Click finish, and the projects get imported. Summary I'm using combinations of both ways: the archive file produced by the export is not different from an archive file I create with my winzip archive utility (or any other tool like this one). for both export ways, I need to manually remove what I do not want in the archive file. I wish there would be better support for this. but for importing projects the import functionality is really good, as it avoids the copy/extract/drag&drop way: I can go through two dialogs, and that’s it. happy export-import ps: thanks to mark ruthenbeck having me considering more the export/import way!
May 10, 2022
by Erich Styger
· 153,364 Views · 8 Likes
article thumbnail
How to Configure Git in Eclipse IDE
Let's get Git configured in Eclipse so you can import and perform operations on repos within your IDE.
Updated May 10, 2022
by Vishwas Sampath
· 46,825 Views · 5 Likes
  • Previous
  • ...
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • ...
  • 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
×