How use Spring with Wicket

این پست حاوی مفهوم بسیار مهمی بنام Dependency Injection (تزریق وابستگیها) با استفاده از فریم ورک اسپرینگ می باشد. هر جایی از این پست را که متوجه نشدین به من ایمیل بزنید تا بتونم همین جا توضیحات بیشتری را اضافه کنم.

فرض کنید میخواهیم یک کمبو را با استفاده از مقادیر موجود در بانک اطلاعاتی پر کنیم.  برای کار با بانک اطلاعاتی یه کلاس نوشتیم به اسم DatabaseHandler . اگه بخواهیم با استفاده از فریم ورک اسپرینگ این کلاس را به لایه ویو تزریق کنیم :

1.برای استفاده از فریم ورک اسپرینگ وابستگی های مورد نیاز را به فایل pom.xml اضافه می کنیم .

2.باید قبل از هر کاری این کلاس را به دوقسمت interface و implementation تقسیم کنیم . یادت نره که تویه کلاس implementation باید Annotation  زیر رو به اول کلاس اضافه کنیم : @Service

3.یک Listener برای استفاده از فریم ورک Spring و یک Filter برای استفاده از فریم ورک Wicket به فایل web.xml اضافه می کنیم.

4.باید به Wicket یه جوری بفهمونیم که ما قصد داریم تویه این پروژه از فریم ورک Spring استفاده کنیم .

How use Spring with Wicket

Add spring dependencies to pom.xml

Divide your business objects in to two parts : 1.interface 2.implementation

Create a Listener element and a Filter element in web.xml for using Spring and Wicket in your web application

Call a method to specify the objects which are injected in your web application

How to populate DropDownChoice using database call

suppose that we want to populate a combo like this with database call in apache wicket


To fill dropdownchoise quicly click on me

To fill in customized manner click on me

For further reading and using spring, please go to this Q&A.


با استفاده از فریم ورک Wicket برنامه نویسی وب شبیه برنامه نویسی Swing وAndroid  میشه و شما هیچ تفاوتی رو احساس نمیکنین. در پست بعدی میگم که چه جوری میشه با کمک فریم ورک Spring وابستگی BO (بیزینس آبجکت) را به لایه ویو Wicket  تزریق کرد.

How to call Mssql Stored procedures using jdbc

there is not needed to use hibernate in every j2ee applications. you can use jdbc simply as defined in the following picture
the code in red color shows how to use log4j for logging sql scripts and the code in brown color shows how to call mssql stored procedures using jdbc.

How to configure connection pooling using JNDI in Tomcat

Create a resource  element in the file server.xml located in CATALINA_HOME\conf

 

Create a resource link in the file context.xml located in directory : META-INF of your project

 

Create a resource reference in the file web.xml in directory : WEB-INF of your project

 

Create a connection object using a JNDI data source