Posts

Showing posts from September, 2020

extracting value from database with hibernateTemplate with where clause

List < Customer > customerList = ( List < Customer >) hibernateTemplate . find ( "FROM Customer c where c . accountNo = ?0 and c . password = ?1 " , accountNo , password ); if ( customerList . size () != 0 ) return customerList . get ( 0 ); return null ;

hibernateTemplate null

 You should always declear everything though bean once using spirng mvc, you cannot make your own class inside. where you have to call other class for service logic.  Only model class can be declear statically

Problem with hibernateTemplate null

Increase Menu Font Size Photoshop, window 10

Image
  Right click on the PS icon in the start menu and choose  Open File Location . Right click on the PS icon you see now and choose  Properties . On the  Compatibility  tab, click  Change high-DPI Settings . Choose  System  or  System (Enhanced)  as below.   Click  OK  and close these Windows. The next time you open Photoshop from this icon, it will scale properly. Repeat this process for any other Shortcuts (desktop/taskbar) that you use to open PShop.

To Use public resources directly in project

< mvc :annotation-driven /> < mvc :resources mapping ="/resources/**" location ="/WEB-INF/resources/" />

Redirection in mvc

@RequestMapping ( "/one" ) public String one () { return "redirect:/enjoy" ; } @RequestMapping ( "/enjoy" ) public RedirectView enjoy () { RedirectView r = new RedirectView (); r . setUrl ( "contact" ); return r ; }

Using of @ModelAttribute

@RequestMapping (value = "/processform" , method = RequestMethod . POST ) public String handleForm ( @ModelAttribute User user , Model m ){ return "contactSucess" ; } // it works three works // replace @RequestParam // do not have use Model // do not need to create model of user and set it in model.setAttribute("user", user) // it can be use on top of method @ModelAttribute public void commonDataForModel ( Model m ) { m . addAttribute ( "Header" , "0BIT1NP" ); m . addAttribute ( "Desc" , "Paving Digital path of Nepal" ); } // this commonDataForModel will execute before other method // Set the value for attribute for all methods

Using of @RequestParam

  public String handleForm ( @RequestParam ( "email" ) String email , @RequestParam ( "password" ) String password , Model model ){ System . out . println ( "Email: " + email ); System . out . println ( "Password " + password ); model . addAttribute ( "email" , email ); model . addAttribute ( "password" , password ); return "contactSucess" ; }

GameEngineKeyEvents

  package com.bithome.events ; import com.bithome.engine.GameContainer ; import com.sun.org.apache.xpath.internal.operations.Bool ; import java.awt.event. *; public class Input implements KeyListener , MouseWheelListener , MouseListener , MouseMotionListener { private final int NUM_KEYS = 256 ; private final int NUM_BUTTONS = 5 ; private Boolean [] keys = new Boolean [ NUM_KEYS ]; private Boolean [] keysLast = new Boolean [ NUM_KEYS ]; private Boolean [] buttons = new Boolean [ NUM_BUTTONS ]; private Boolean [] buttonsLast = new Boolean [ NUM_BUTTONS ]; private int mouseX , mouseY ; private int scroll ; private GameContainer gc = null ; public Input ( GameContainer gc ) { this . gc = gc ; mouseX = 0 ; mouseY = 0 ; scroll = 0 ; gc . getWindow (). getCanvas (). addKeyListener ( this ); gc . getWindow (). getCanvas (). addMouseWheelListener ( this ); gc . getWindow (). getCanvas (). addMouseMot

GameEngine with loop

  public class GameContainer implements Runnable { public static int scale = 6 ; public static int w = 100 , h = ( w * 16 ) / 9 ; public static String title = "BitHomeEngine" ; private float UPDATE_CAP = 1 / 60f ; private boolean running = false ; private Window window = null ; private Thread thread = null ; public void initialize () { window = new Window (); thread = new Thread ( this ); } public void start () { initialize (); running = true ; thread . run (); } public void run () { boolean render; double firstTime = System .nanoTime() / 1000000000.0 ; double passedTime; double unprocessedTime = 0.0 ; double lastTime; while ( running ) { render = false ; lastTime = System .nanoTime() / 1000000000.0 ; passedTime = lastTime - firstTime; firstTime = lastTime; unprocessedTime += passedT

GameEngine for updating image

  import com.sun.imageio.plugins.jpeg.JPEGImageMetadataFormatResources ; import javax.swing. *; import java.awt. *; import java.awt.image.BufferStrategy ; import java.awt.image.BufferedImage ; public class Window { private Canvas canvas ; private JFrame frame ; private BufferedImage image ; private BufferStrategy bs ; private Graphics g ; public Window () { image = new BufferedImage ( GameContainer . w , GameContainer . h , BufferedImage . TYPE_INT_RGB ); canvas = new Canvas (); Dimension dimension = new Dimension ( GameContainer . w * GameContainer . scale , GameContainer . h * GameContainer . scale ); canvas . setPreferredSize ( dimension ); canvas . setMinimumSize ( dimension ); canvas . setMaximumSize ( dimension ); frame = new JFrame ( GameContainer . title ); frame . setPreferredSize ( dimension ); frame . setLayout ( new BorderLayout ()); frame . add ( canvas ,

SpringMVC sending data from controller to view and vice versa

1) Model   Model will be place in the method parameter. We have to use model.addAttribute(String key, Object value) @RequestMapping ( "/home" ) public String home ( Model model ){ model . addAttribute ( "name" , "Himal" ); model . addAttribute ( "id" , 2225 ); return "home" ; } 2) ModelAndView With model and view, define it inside method. ModelAndView modelAndView = new ModelAndView("pagename"); return modelAndview @RequestMapping ( "/help" ) public ModelAndView help (){ ModelAndView modelAndView = new ModelAndView ( "help" ); String s = "this is help" ; List < String > stringList = new ArrayList <>(); stringList . add ( "Me" ); stringList . add ( "Myself" ); modelAndView . addObject ( "stringList" , stringList ); modelAndView . addObject ( "s" , s ); return modelAndView ; }

SuperKey in my computer

 between altgr and option's window flag key

Shortcut for selecting multiple line or multiple crusor

Alt + shift + mouse click 

Basic calculator php

  <! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > PHP Learning </ title > </ head > < body > < form method = "GET" > < label > First num: </ label > < input name = "firstnum" type = "text" /> < label > Second num: </ label > < input name = "lastnum" type = "text" /> < label > Operation </ label > < input name = "operation" type = "text" /> < button type = submit > submit </ button > </ form > <?php $first = $_GET [ 'firstnum' ]; $second = $_GET [ 'lastnum' ]; $op = $_GET [ 'operation' ]; switch ( $op ){

define variable, take input from form and display in browser through php, DATATYPES

  <! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > Document </ title > </ head > < body > < form method = "POST" > < input name = "person" type = "text" /> < button type = "submit" > submit </ button > </ form > <?php $name = "Himal " ; // $ sign will make a variable $lastname = "puri " ; echo $name . $lastname . " is a good man" ; // Unlike in javascript and java, we have to use . after // variable to connect with it another variable $num = 5 ; $num2 = 10 ; echo $num + $num2 ; $person = $_POST [ 'person' ]; echo $person . "is a g

Intro to php, print and echo

// To use php download xampp server, go to opt/lampp/htdocs delete all file inside and make index.php file run apache server. // Print and echo <! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > Document </ title > </ head > < body > <?php echo "This is the php fil <br>" ; print "This is the php another file<br>" ; // Both echo and print are same. // echo is a bit faster than print print 12 ; // Integer need not to put inside the double quote echo 10 + 5 ; // Can do math function easily ? > </ body > </ html >