Thursday, 21 September 2023

Java Application

Java Application

  • Using the Java programming language, we can create two main types of Java applications: standalone applications and Enterprise applications.
Standalone Applications

  • If we design and execute any java application without using client-server architecture than that java application is called as Standalone application.

  • Two types of Standalone application
  1. CUI Application (Characters User Interface)
  • It will be designed in such a way to take input data from users through command prompt and to provide output data to the user through the same command prompt, where the command prompt is acting as an user interface.
  • It is supporing characters data.

2.   GUI Application(Graphical User Interface)                         
  • It is standalone application, it will be designed such a way to take input from users through the collection of graphics component and to provide out data to the users through the same collection of graphics components.
  • It is supporting graphic data.
  • To prepare applications, java has provided some core libraries
  • i.e: java.lang, java.io, java.util, java.awt, javax.swing etc.

Enterprise Application
  • If we design execute any java application on the basis of client-server architecture or by distributing application logic over multiple machine then that java application is called as Enterprise Application.
Two types of Enterprise Application

  1. Web Application
  • It is a client-server application, where the complete application logic will be distributed over server machine.
  • In web Application client must be browser.
  • JVM is required for server side.



2.Distributed Application
  • Distributed application is a client-server application, where the complete application logic will be distributed over both client and server machine.
  • In Distributed application client may be a java program servlet, JSP Page framework, structs, spring application.
  • JVM is required for both client-server side.


Difference B/W Web Application and Distributed Application





What is the purpose of web application?
  • The purpose of web application is to provide dynamic response from server machine.
What is the purpose of Distributed application?
  • The purpose of distributed application is to establish communication b/w local machine & Remote machine services from Remote machine to local machine.

In Web application , there are Two types of Response
  1. Static Response
  • Static response is the response generated from service without executing any resource from server machine and without performing any action at server machine.

2. Dynamic Response
  • If we generate any resource from server by executing a particular resource or by performing an action at server machine than that response is called Dynamic Response.
  • To generate dynamic response server has to execute an application at server machine called as web application.
  • To prepare web applications at server we have to use a set of tech called as webTech.
  • for eg:- CGI, Servlets JSP etc.

Thanks
Matri Sharma

Monday, 18 September 2023

Query builder in AEM(Basic Structure)

  • If we talk about Search API in AEM there is Two main options available.
    • QueryBuilder
    • JCR SQL

  • What is Query Builder?
     The Query Builder in AEM is a framework and toolset that allows         developer and content authors to create and execute complex             queries to retrieve content from the AEM repository. It provides       a simple and efficient way to search for and access content based       on various criteria.                                              

  • How you can Write and execute Query Builder?
    There is a Console available in AEM where, we can write and test      our Query.
    Query Builder debugging tool allows you to interactively create,      test, and debug queries 
   URL :http://localhost:4502/libs/cq/search/content/querydebug.html 
  • Where does the Query Builder store data in the JCR.?
The data in the JCR is stored as a hierarchical structure of nodes and properties.
/libs/cq/search/content/querydebug

There is a console to test your query using this path http://localhost:4502/libs/cq/search/content/querydebug.html



  • When you write the query builder first you have to define what kind of node you want to search using as a generic term as a node you can define page, asset some any kind of node so whatever the primary type available in AEM you can search that any        available primary type so, first we have to define type.
  • In type we have to decide what you want to search suppose, I want to search pages so, the primary type of pages are cq:Page.


  • So, using this query we found all pages available in my repository .
  • But it's not right query total no of pages is 1750 but, it is showing only 10 pages name.
  • So, the solution is firstly we define the path and the path query is type=cq:Page


  • show 19 pages and the result is show 10 For change this behavior we can define One parameter i.e: p.limit.
  • p.limit can define how many results we want to search.
  • Basically, p.limit will be used when we implement Pagination.

  • for eg: we put p.limit=5, than Number of hits is 19, but results are 5.
  • If we want all results display than, we write p.limit=-1.
  • If we want some specific template so, let's see how we add any property and how we will search based on property.
  • property=cq:template and than, property.value= whatever the property of value.



  • AS soon as hit that search button the number of hits is 0. so, let's see what is the issue here.
  • We are trying to search cq:Page we are using node it means the page we should have a property so, if we go there in repository and check this node does have property called cq:template that is the reason result showing 0.
  • Let 's see how to resolve this problem if we see all the data store in jcr:content  and this has primary type cq:PageContent





  • In this Query might be missing some value than we are searching page not page content so keep type=cq:Page itself and search the relative path [It means properties on related path] It means /page there is a node jcr:content than we add relative path.

  • In each hit having a page rather than the page content.
  • If we want to search multiple of same property than using jcr:title.

  • Only single property we defining multiple value using property.1_value= title name.
  • By default it has or value if we want to make it end than, we are using propery.and=false by default it is false, if we make it true than the result is 0.
  • Because title does not have both 

  • Now we want to use multiple properties.
  • For multiple properties we are using prefix before properties rather than before value.

  • Suppose we want or condition it means either template is home or title is xml.
  • So, for that we have define groups



  • If there is no homepage template, why is the number of hits not 0? Let's see what the reason is
  • It is coming on search because the title is xml present.

  • How to know the data of each search result?
    • There is a option of JSON QueryBuilder Link click on this so, we will find in json what data is coming so it will giving all results. 



  • If we want order of these last modified date so we search orderby=@jcr:content/cq:lastModified


  • By default it is an ascending order.
  • If we want descending order so we search orderby.sort=desc.

Thanks
Matri sharma

Servlet in AEM/Sling Servlet

  What is Servlet? A servlet is a Java class that runs on the server side where the application resides. It acts as a middle layer between t...