Thursday, 9 June 2016

how to add the local project to a new repository in github

In many cases, I create the project locally, develop it. And then I realize that it would be great if its available it Github. This is more of like, bottom-up approach.

Following is the list of steps to achieve this.

  1. Create the remote repository, and get the URL such as git@github.com:/youruser/somename.git or https://github.com/youruser/somename.git
    If your local GIT repo is already set up, skips steps 2 and 3

  2. Locally, at the root directory of your source, git init
    2a. If you initialize the repo with a .gitignore and a README.md you should do a git pull {url from step 1} to ensure you don't commit files to source that you want to ignore ;)
  3. Locally, add and commit what you want in your initial repo (for everything, git add . then git commit -m 'initial commit comment')

  4. to attach your remote repo with the name 'origin' (like cloning would do)
    git remote add origin [URL From Step 1]
  5. to push up your master branch (change master to something else for a different branch):
    git push origin master
  6. Execute git pull origin master to pull the remote branch so that they are in sync.

Wednesday, 8 June 2016

Generate Service Endpoint for SOAP webservices using Apache CXF

This blog is to explain on how to generate the Web service client interfaces for the SOAP web service using Apache CXF.

1) Generate the WSDL file out of SoapUI tool or through any web browser by giving the WSDL URL. Save the generated the file as PurchaseOrder.wsdl

2) Download the CXF2.7.11 from the apache website into the local drive. Then, refer that path in to Eclipse->Windows->Preferences->Webservices->CXF. Please refer the screenshot below.




3) Create a Dynamic web project named WS-SEI with default values.

4) Add the CXF library files from the downloaded one to the above project, so that wsdl2java program of CXF will run without any issues.
5) Move the wsdl file (PurchaseOrder.wsdl) into the Webcontent of the above project
6) Select the above project->File->New->Other->Web Service Client.
7) Select the WSDL file from the project for which you want to create the web service client files.
Change the Web Service Runtime to Apache CXF 2.x (Default value is Apache Axis)



8) Click Next and then select the source directory of the project where you want to create the client files.
9) Enter the Package name to bundle the client files (in this case, com.cfa.webservice.client.purchaseorder)
10) Select the check box “Specify WSDL Namespace to Package Name Mappings”
11) Select the check boxes that are selected in the attached screen below and then click Next


The new window will open. Just click Finish to generate the client files.


This will generate the list of Java classes with the sample date to invoke the web service. The program can be executed as a Core Java application or can be integrated with the web application to invoke the SOAP web service.

Monday, 6 June 2016

Different functionalities on Dropdown or Select box

I have listed down all the possible combinations of using Dropdown box using jQuery.

Pre-Select:

The dropdown is filled with the values and when the form is loaded, a particular value needs to be highlighted (The value may come from database or the default value).

$("#myList option[value='"+ MY_VALUE+"']").prop('selected',true);

----------------------------------------------------------------------------------------------------------------------

Create List:

Sometimes, there are cases where the list need to be created at run time. Following is the piece of code to create the list.

var options = '<option value="' + "ALL" + '">'
                  + "ALL" + '</option>';
         $.each(myList, function( index, value) {
      options += '<option value="' + value+ '">'
                      + value+ '</option>';
      });
     
        $("select#finalList").html(options);

----------------------------------------------------------------------------------------------------------------------

Default to First Item:

$('#myList').get(0).selectedIndex = 0;

----------------------------------------------------------------------------------------------------------------------

Enable/Disable or grey out the fields using jQuery

Even after working on many applications, I tend to google for disabling some of the fields in the application using jQuery. Following is the list of components and the way to disable/enable or grey out the fields.

Input Box:

$("#title").attr('readonly', true); -- To Disable
$("#title").attr('readonly', false); -- To Enable

Check Box:

$("#title").attr('disable', true); -- To Disable
$("#title").attr('disable', false); -- To Enable

Select or Dropdown Box:

$('select#myList').attr('disabled', true); - To Disable
$('select#myList').attr('disabled', false); - To Enable

Span:

$("#mySpan").css("pointer-events", "none"); - To Disable
$("#mySpan").css("pointer-events", "auto"); - To Enable

Button:

$("#myButton").prop('disabled','disabled'); - To Disable
$("#myButton").prop('disabled',''); - To Enable