Search This Blog

Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Have you discovered yourself in prevailing pandemic lockdown - Covid 19 in 2020? - By Hardik Patel

 
 

Every fade has a fall for sometime and so this growing pace too. It could take only 6 to 7 months for a tiny virus to grow in more than 125 countries. Does this call for a cause? Well its not a cause but seems to be a curse of how a man is a bundle of desires. We are not even a size of a virus against the nature and if we really have not understood these things, we are surely at a wrong race trust me.
 

Every luxury and lifestyle arrangements are affected but have you seen any impact on the water, air, fire and other forms of nature? Contrary they have purified but are we also purified on our thoughts? This uncertainties have brought lot of eye openers and those are points of discussions exactly on how we should learn things for not grooming and look decent to others but to curate ourselves as to how are we well prepared post this time to evaluate on knowing our souls and our heart which is loaded with the fake commitments and wrong requirements in life.

This time calls for a moment to think why do you be known to the world and why do you exist in this world? Is it because of the fulfillment's of other's dream or is it for the betterment of the society? Giving donations to poors or want to do something for poors? It can be so soothing and cool to be a part of the community by engaging ourselves on innovations and betterment of the community. Of course money will fall on you if these are done with the pure commitments. Falling money here I mean by is the karma's return and not money earned by doing something wrong.

Time is endless and it just ends for those who are done. You need to press hard the surface to extend the more seconds and minutes on life for regenarting and reopening up of our minds on how are we going to do something really different in this new normal.

We are not even a small hair in the entire galaxy, don't try to mess with nature, be natural on your thoughts and reinvent yourselves.

A small ending thought - cooking new dishes in this time is a waste of time if that is not helping the community.

We should spread equal love for community. We are the same as our color of the blood is same. Be wise and reinvent yourself.
 
- From a small piece of shit

How to create a war file directly inside jboss deployments folder(external folder) using maven in pom.xml

Kindly keep a configuration as below mentioned :
 
    Pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.seedsofjava.blogspot.com</groupId>
 <artifactId>abc</artifactId>
 <packaging>war</packaging>
 <version>1.0</version>
 <name>abc</name>
 <build>
 <finalName>abc</finalName>
 <pluginManagement>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>3.5</version>
 <configuration>
 <source>${java-version}</source>
 <target>${java-version}</target>
 </configuration>
 </plugin>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-war-plugin</artifactId>
 <configuration>
 <warName>abc</warName>
 <warSourceDirectory>src/main/webapp</warSourceDirectory>
 <failOnMissingWebXml>false</failOnMissingWebXml>
 <webResources>
 <resource>
 <directory>lib/</directory>
 <targetPath>WEB-INF/lib</targetPath>
 <includes>
 <include>**/*.jar</include>
 </includes>
 </resource>
 </webResources>
 <outputDirectory>C:/Softwares/jboss-eap-7.0/standalone/deployments</outputDirectory>
 </configuration>
 </plugin>
 </plugins>
 </pluginManagement>
 </build>
</project> 

How to compare two string dates in hibernate using criteria if DB field

 
It is very simple and easy to do in hibernate using criteria condition. Let's say we have two fields like from date and to date As "String". 

First we should consider below mentioned conditions while developing it

It will be like below cases: 
  1. User select fromdate and didnt select todate than 'it should fetch all records from fromdate to systemdat'
  2. if user select only todate and not formdate than it should fetch all record till todate
  3. If user enter both than it should filter the record in date range and display
  4. If fromdate > todate then we should through error 
  5. Both are not given than it should find all the records till Systemdate i.e. Today
Code will be look like something as :
 Hibernate DAO layer:
if(!Utils.isNullOrEmpty(model.getDateFrom()) && !Utils.isNullOrEmpty(model.getDateTo())) { cr.add(Restrictions.sqlRestriction("TRUNC(COLUMN) >= TO_DATE('" + model.getDateFrom() + "','dd/mm/yyyy')"));
 cr.add(Restrictions.sqlRestriction("TRUNC(COLUMN) <= TO_DATE('" + model.getDateTo() + "','dd/mm/yyyy')"));
 }
 else if(!Utils.isNullOrEmpty(model.getDateFrom()) && Utils.isNullOrEmpty(model.getDateTo())) {
 cr.add(Restrictions.sqlRestriction("TRUNC(COLUMN) >= TO_DATE('" + model.getDateFrom() + "','dd/mm/yyyy')"));
 //cr.add(Restrictions.sqlRestriction("TRUNC(COLUMN) <= TO_DATE('" + Utils.formatNewDate() + "','dd/mm/yyyy')"));
 }
 else if(Utils.isNullOrEmpty(model.getDateFrom()) && !Utils.isNullOrEmpty(model.getDateTo())) {
 cr.add(Restrictions.sqlRestriction("TRUNC(COLUMN) <= TO_DATE('" + model.getDateTo() + "','dd/mm/yyyy')"));
 }
Utils.java:
public class Utils {
 public static Boolean isNullOrEmpty(String str){
 return (str != null && !str.isEmpty()) ? false: true;
 }
}

Best way to use Spring MVC ModelAttribute field in JSTL/JSP page in c:if

        Let's say that you want to hide/show in GUI based on Spring MVC @ModelAttribute field, Kindly follow below mentioned steps :

Guess that you have one UserModel with field saveButton as string type for storing true/false.

UserModel.java

public class UserModel {
    private String saveButton = "true";
}

UserDetails.jsp
<c:if test="${userModel.saveButton == 'true'}">
	<input type="submit" class="btn btn-primary btn-sm" id="saveUserDetails" name="method" value="Save">
</c:if>

In this best way, we can achieve to hide/show button in spring mvc.

Are You A Thinker Or Maybe It's Overflowing?

Hi, everybody. I'm Rohit Patel and I'd like to ask you today, "Are you a thinker Or maybe it's overflowing? Do you live in ...

Popular Posts