Java Frameworks

Java | Delete empty string from list or array

Author - Webner

public class deleteEmptyStringQuick
{
public static void main(String[] args)
{
String[] emptyStringArray={“test”,”test1″,””,”test3″,””,”test4″};
ArrayList arrayListOfEmptyString=(ArrayList) Arrays.asList(emptyStringArray);

//normally we will do this
ArrayList filteredList = new ArrayList();
for(String string: arrayListOfEmptyString)
{
if(!string.isEmpty())
{
filteredList.add(string);
}
}

//You can achieve this with single line as well:
filteredList Read more…

Salesforce | Change value of an object’s field on button click and reload page

Author - Webner

We can change the value of an object’s field on button click by using javascript like this (and this will also reload the page):
{
!REQUIRESCRIPT(“/soap/ajax/29.0/connection.js”)
}
var rec = new sforce.SObject(“Contact”);
rec.Id = “{!Contact.Id}”;
rec.IsActive= ‘true’;
var result = sforce.connection.update Read more…

Java | Configure Tomcat as a service on linux

Author - Navneet Kashyap

Configure Tomcat service in Linux:

These instructions are related to installing and running Tomcat 7 as a service, which means that it will be launched at system boot and will be closed properly on system shutdown.

Running tomcat as a service in Linux:

For security reasons, you should not run Read more…

ACORD Forms autofill

Author - Webner

We get this request from a lot of clients in US insurance industry who want to generate ACORD forms automatically, means they want data of corresponding insurance Policy and other objects filled automatically in the editable ACORD PDF. Most of the clients have their data in a CRM system like Read more…

java.sql.SQLException: Data truncated for column date at row 1

Author - Webner

You may face this exception while trying to insert data in a mysql table using hibernate:

java.sql.SQLException: Data truncated for column date at row 1

While there can be different reasons of this problem, in our case it was occurring because by mistake we were trying to insert Read more…

Zoho Creator or PHP based solution?

Author - Webner

A lot of Zoho users want to extend the capability that Zoho CRM provides out of the box. For example, one of our clients wanted to build a custom Quote Generator. They initially wanted to get the customization done to default Zoho CRM Quote form but their requirements were not Read more…

Execute Javascript code on browser back button

Author - Kritika Sood

Here is sample code to trap browser back button and execute Javascript code on this event:

jQuery(document).ready(function($)
{
if (window.history && window.history.pushState)
{
$(window).on(‘popstate’, function() {//when back is clicked popstate event executes
//code here will execute on back click
});
}
});

Webner Solutions is a Software Development Read more…

Java | Execute SQL script using Maven

Author - Rita

Whenever there is a change in the database whether we are altering database structure or adding/updating data inside database most of the times we create a script file and run it manually. We can automate this process using Maven.

Solution: Maven provides a plugin called flyway-maven-plugin to Read more…

Linux | Configure Tomcat service in linux

Author - Navneet Kashyap

Running Tomcat as a service in Linux:

For security reasons you should not run Tomcat as root service. It is better to create a new user and run Tomcat under it.

Create a file with the script:
$ sudo vi /etc/init.d/tomcat
(add following and set path of tomcat Read more…

Moodle/Totara | HTML Editor doesn’t show up on summary area

Author - Webner

If HTML editor does not show up on summary area verify whether the editor has been enabled using the admin login to Moodle / Totara. This can be verified by checking the following points (in no particular order):

1. Is the TinyMCE HTML editor enabled in Settings > Site administration > Plugins > Text Read more…

Salesforce | Refresh the parent window automatically on closing the child window

Author - Webner

On closing child popup window (on click of a button), we wanted to refresh the parent window automatically to check the updates.

We can refresh the parent window on closing the popup window by using javascript.

Syntax : This is sample javascript code of page loaded in popup:

<apex:page Read more…

Java | Check if domain of an email address is valid or not

Author - Neha Mishra

To Check if the domain of an email address is valid or not, pass the email address to the below method as an argument and execute it, it will return true or false by checking if the email id you entered has valid domain or not :
private static boolean doLookup Read more…

PHP | Sorting Complex Multidimensional Array

Author - Ishpreet Kaur

Suppose we have a complex array like below:

$products = array(
array(
‘product’ => array(‘id’ => 1, ‘name’ => ‘Jquery tutorial book’),
‘product_details’ => array(‘cost’ => 10, ‘edition’ => ‘first’)
),
array(
‘product’ => array(‘id’ => 2, ‘name’ => ‘javascript tutorial book’),
‘product_details’ => array(‘cost’ => 20, ‘edition’ => ‘first’)
),
array(
‘product’ => array(‘id’ => 3, ‘name’ => ‘C++ tutorial book’),
‘product_details Read more…

How to create a dynamic div using Javascript

Author - Webner

Here is sample code if you want to create a dynamic div using Javascript:

<script type=”text/javascript”>
divCount =0;
function createDiv()
{
var divTag = document.createElement(“div”);
var studList =””;
studList += ‘<select id=”BOX_’+divCount+'” name=”BOX_’+divCount+'”>’;
studList += ‘<option value=””>— Select —</option&gt Read more…

Javascript | Unable to get content of HTML while converting HTML page to PDF

Author - Webner

Problem : Unable to get content of HTML while converting HTML page to PDF.

Solution : You can use the javascript if you want to get content of HTML while converting it into PDF :
<HTML>
<head>
<script type=”text/javascript”>
function submitForPDF()
{
document.getElementById(“mybutton”).style Read more…

HTML text box should only accept numbers and dot

Author - Kailash

You can use the following javascript code to check textbox value:

<html>
<head>
<script language=”Javascript”>
function isNumberKey(evt)
{
var re=new RegExp(/^[0-9]*.?[0-9]*$/);
if(document.getElementById(“text”).value.match(re))
{
alert(“match”);
}
else
{
alert(“no match”);
return false;
}
}
</script Read more…

Javascript Calendar Problem on Chrome and Safari browsers

Author - Kritika Sood

While working in a project, we faced a problem with using a calendar on a webpage. It was working fine for Mozilla Firefox but not for Chrome and Safari.

Initially we had this code:

<input type=”text” name=”startdate” id=”startdate” class=”form-control datepicker” placeholder=”Financial Year StartDate Read more…

Java | Maven | How to pack Maven dependencies while creating jar file

Author - Rita

We were creating a Maven project having packaging type jar. We had main class from where we were starting project execution. It was working fine through Eclipse but when we created jar file by compiling with Maven, we were not able to run the jar as it was throwing missing Read more…

Eclipse | Generate client for RPC based web services

Author - Rita

1. Select your project where you want to generate client code for your wsdl file:

2. Select File -> new -> other option from drop down menu as shown below:

Select web service client option from the drop down and click on next button.

3. Add your Wsdl URL to Read more…

Salesforce | How to set value of input text field on parent Visualforce Page using Javascript

Author - Webner

Description: We had a text field (inputTextF) on our parent page. We wanted to set its value from inside my child page programmatically.

1. You need to pass parent page element Id to the child page.

2. Get parent page element Id on child page using CurrentPage.parameters Read more…