Welcome to my blog, hope you enjoy reading
RSS

Friday, 7 March 2014

Handling multiple updates in Mysql

Handling multiple updates in Mysql 

UPDATE yourtable
    SET updatefield = CASE id
        WHEN 1 THEN 'new value'
        WHEN 2 THEN 'new value'
        WHEN 3 THEN 'new value'
    END
WHERE id IN (1,2,3)
Share

Tuesday, 4 March 2014

CPU usage in ubuntu

CPU usage in ubuntu 

You first should figure out what process is eating away your CPU.
  •     open a terminal with ctrl+alt+t
  •     execute the command top
  •     note the process using the most cpu
If the process isn't a system process, kill it with sudo pkill [processname] with [processname] the name of the process you want to kill. If it is a system process, don't kill it, but try to google the name and figure out what functionality it has in Ubuntu. Then you can proceed to turn it of (in e.g. you system settings).
Share

Monday, 24 February 2014

Project facet Java version 1.7 is not supported

Project facet Java version 1.7 is not supported 

When i update my java I found the issue "Project facet Java version 1.7 is not supported" To resolve this issue follow the steps.
  1. Go to Ecllipse , right click on your project folder
  2. select the properties
  3. now select Project Facets ,here you will see java, click on the version and change the higher version to lower or as per your requirement .

Share

Sunday, 23 February 2014

How to Use RichTextToolbar in GWT

How to Use RichTextToolbar in GWT 

If you’ve ever tried to use the RichTextToolbar that is showcased in the Gwt Showcase, you will quickly find out that it’s not actually built into GWT.  Many GWT developers have experienced this WTFery, as their hopes to conveniently import RichTextToolbar have been dashed.  It is supposedly so that developers are not locked into using that toolbar, but of course, a good default is better than no default…

As you can see here, multiple bugs have been filed about this exact issue since 2008, to no avail!  Drats, I guess it is one of those things that has low priority because there’s a work-around, but it does affect a good number of developers, which should count for something.

Anyway, to use it in your code:

  •     Navigate to <path>/gwt-2.0.3/samples/Showcase/src/com/google/gwt/sample/showcase/client/content/text on your computer, and you should see a bunch of icons, RichTextToolbar.java and RichTextToolbar$Strings.properties.
  •     Copy RichTextToolbar.java and RichTextToolbar$Strings.properties and paste them into your source code folder and modify the package names accordingly.
  •     Copy all the icons and paste them somewhere (I created a folder  <project>/client/icon)
  •     In RichTextToolbar.java, above each “Image Resource…”, you will need to indicate the source of the image.  For example,

    @Source(“../icons/bold.gif”)

    ImageResource bold();

    if the directory you copied RichTextToolbar.java is under client.

That’s it, a little annoying, but hopefully it will find its way into GWT itself soon, though don’t hold your breath.

Also, you can easily play around with the Toolbar– I removed the bottom row of ListBoxes that give you lots of control over background and foreground colors, font and font sizes (I don’t want my users to have that much control over how my website looks!), and it ends up looking like this:

Hope that helps, and that it will save a few people some time!

Related posts:


Share

Allow only Numeric in HTML inputbox

Allow only Numeric in HTML inputbox Following code is used to allow only numeric (0-9).

<script language="Javascript">
      function isNumber(evt) {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;
 
         return true;
      }
</script>
 
<input onkeypress="return isNumber(event)" type="text">


Another Way

Following code is used to allow only numeric (0-9).
   
<script language="Javascript">
     function validate(evt) {
      var theEvent = evt || window.event;
      var key = theEvent.keyCode || theEvent.which;
      key = String.fromCharCode( key );
      var regex = /[0-9]|\./;
      if( !regex.test(key) ) {
        theEvent.returnValue = false;
        if(theEvent.preventDefault) theEvent.preventDefault();
      }
    }
</script>
 
<input onkeypress="return isNumber(event)" type="text">

Share

STRUTS : java.lang.IllegalAccessException

STRUTS : java.lang.IllegalAccessException

STRUTS : java.lang.IllegalAccessException: Class org.apache.struts.util.RequestUtils can not access a member of class view.myAction with modifiers "

Share

Thursday, 13 February 2014

Wampserver : #1045 – Access denied for user ‘root’@'localhost’ (using password: NO)

Here is a simple way to solve #1045 – Access denied for user ‘root’@'localhost’ (using password: NO) error…

Just follow the steps:

Note: [WAMP_PATH] is the path to the wampserver directory in your computer so it can be anything. Default (C:\wamp).

   1. First, go to [WAMP_PATH] > apps > phpmyadmin3.5.1.
   2. Then find and open config.inc.php in your text editor
   3. Now find $cfg['Servers'][$i]['password'] = ”; and change it with $cfg['Servers'][$i]['password'] = ‘admin’; (You can put anything in place of admin as your password, this is only a test password).
   4. Now find $cfg['Servers'][$i]['AllowNoPassword'] = true; and replace it by $cfg['Servers'][$i]['AllowNoPassword'] = false;.
   5. Thats it now save that file.
   6. Now restart the wampserver. To do this left-click the wamp icon in the windows taskbar (Notification one), a box will pop up then just click on Restart all Services.

Yeah! You have successfully resolved the error. If you face any error make sure to comment or email me.


For login page getting
1.find $cfg['Servers'][$i]['auth_type']  and change the value like
$cfg['Servers'][$i]['auth_type'] = 'cookie';
2.save the page.
3.restart the server.
for info see the link video.

Share

Saturday, 1 February 2014

How to swap keys and values in a Map

How to swap keys and values in a Map 



package com.javanotes2all.java.collectionfw;

import java.util.HashMap;
import java.util.Map;

public class SwapKeysAndValuesinMap {

 public static void main(String[] args) {
  HashMap map=new HashMap();
  map.put("1", "a");
  map.put("2", "b");
  map.put("3", "c");
  map.put("4", "d");
  map.put("5", "e");
  map.put("6", "f");
  map.put("7", "g");
  System.out.println("before swap"+map);
  map=reverse(map);
  System.out.println("after swap"+map);
 }
 public static  HashMap reverse(Map map) {
     HashMap rev = new HashMap();
     for(Map.Entry entry : map.entrySet())
         rev.put(entry.getValue(), entry.getKey());
     return rev;
 }
}


Share

Thursday, 23 January 2014

GWT KeyPressHandler getCharCode issues

GWT KeyPressHandler getCharCode issues 

  • event.getNativeEvent().getKeyCode()
  • KeyCodes.KEY_ENTER=13
This code returns the '10' in chrome so the following code is not working.
  • if(event.getNativeEvent().getKeyCode()==KeyCodes.KEY_ENTER)
This code returns the '13' in firefox so the following code is working. 

so like the code like following for both chrome and firefox
  • if(event.getNativeEvent().getKeyCode()==13)
  • {
  • //Do something
  • }else if(event.getNativeEvent().getKeyCode()==10)
  • {
  • //Do something
  • }



Share

Sunday, 12 January 2014

How to execute Runnable file in Ubuntu 13.10

How to execute Runnable file in Ubuntu 13.10 

Open the file manager, go to the Files menu and select Preferences to open the "Preferences" dialog.

In the Behaviour tab activate the option Run executable text files when they are opened in the Exexcutable Text Files section:


 
Share