tag:blogger.com,1999:blog-66129731320265733282024-03-24T02:20:58.287-07:00Programming Tips.Please be careful with NCBA Asset finance.http://www.blogger.com/profile/10733977270923746953noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6612973132026573328.post-35359226185802764972015-07-14T19:49:00.001-07:002015-11-09T23:15:17.474-08:00Connect Android To Java REST Web Services And MySQL.Sometimes you want to make a mobile application that sends and receives
data from the database. While JDBC library can help you achieve that,
its a good practice that you create a web service to act as an
intermediary. Using JDBC creates vulnerability because you will have to hard code you r database login credentials in your application code. An
attacker would simply have to reverse engineer your code and read all of
the details. Using web services does not only increase security but, it
prevents redundancy. All queries and transactions are done at the web services layer. With this kind of a set up, different platforms can
utilize the web service without rewriting any code. The general
architecture looks like this. <br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0a0k36nZA52EBE21t4WJoVJj-vSG0uTnyci8h8GPGgJqy5fhfqByHp2EjSXeHCi175WKveGd859dxf_DdJFh03WCYd7v7cIe_E4OdkKXrh7fAS3RXBrCM4IGN77q5f-icqWxaKBVAAPc/s1600/turoial+webservices.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0a0k36nZA52EBE21t4WJoVJj-vSG0uTnyci8h8GPGgJqy5fhfqByHp2EjSXeHCi175WKveGd859dxf_DdJFh03WCYd7v7cIe_E4OdkKXrh7fAS3RXBrCM4IGN77q5f-icqWxaKBVAAPc/s320/turoial+webservices.png" /></a> </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Please check this tutorial <a href="http://androidtesstwo.blogspot.co.ke/2015/07/jasper-report-with-netbeans-ide_74.html" target="_blank">here</a> and set up a database with this structure </div>
Please be careful with NCBA Asset finance.http://www.blogger.com/profile/10733977270923746953noreply@blogger.com0tag:blogger.com,1999:blog-6612973132026573328.post-42091342933931697092015-07-13T08:13:00.001-07:002015-08-24T02:24:33.806-07:00Jasper report with netbeans IDE, mysql,JavaEE, Primefaces. part 4<div class="fln-affiliate" data-qts="//t.flnaffiliate.com/" data-size="336x280" data-style="" data-theme="faces" data-type="banner" data-username="solokingjec11">
</div>
<script type="text/javascript">(function(d) {
var po = d.createElement('script');
po.type = 'text/javascript'; po.async = true; po.src = '//static.flnaffiliate.com/build/js/affiliate-sdk.js';
var s = d.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})(document);</script>
Hello guys.<br />
This is the last part of the tutorial series.<br />
In this part, we will design a report using iReport plugin inside netbeans IDE.<br />
In our web page folder, create a new folder call it jasper.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNh9HCzDmNCMFLcXI4gn0_-un3Up_62qMHyov27DgBJK9eWka-z7uiPUus7WCbKz9jTHy84j0XEARb8N39tgQS-2Yde2VeuF8RjoVn_xBgpjOKgr0WUf4-U991pKKFB7j9J5Fc9hmHdZs/s1600/newfoler.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNh9HCzDmNCMFLcXI4gn0_-un3Up_62qMHyov27DgBJK9eWka-z7uiPUus7WCbKz9jTHy84j0XEARb8N39tgQS-2Yde2VeuF8RjoVn_xBgpjOKgr0WUf4-U991pKKFB7j9J5Fc9hmHdZs/s1600/newfoler.png" /></a></div>
<br />
Right click on the folder and go to new>File>Other in the
category, select Report and pick empty report. We want to keep things as
simple.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVXGfzxyYPpGgwgSmvVR1OxiqkgzuKCWVzLh1JnU5RlSi9rHoRaof2XQ872wn8iMa-g1Q9-5arDGIFQwEjqi9abIJ0797Kj7pvImNuo_XkyD5mshwAgtuP0wkhBzJCJGvvzf5ZKC2UhnI/s1600/newreport.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="142" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVXGfzxyYPpGgwgSmvVR1OxiqkgzuKCWVzLh1JnU5RlSi9rHoRaof2XQ872wn8iMa-g1Q9-5arDGIFQwEjqi9abIJ0797Kj7pvImNuo_XkyD5mshwAgtuP0wkhBzJCJGvvzf5ZKC2UhnI/s320/newreport.png" width="320" /></a></div>
Give it the name employeelist.<br />
<br />
A blank report will appear in the designer tab like this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtb2GkZ9VqmPLej_qSvuO0x21dm_ZtjALI2WUnS1vK8PMev-yWbBu8ot4NNInunsKxkRz-nI2mRDmU3wFZfIyMaQjUDvZ9pLcmfpg9Xbqtp9D-7K2IVS1ZNYoFQiDbZm7HqkaL4BSz1do/s1600/emptyreport.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtb2GkZ9VqmPLej_qSvuO0x21dm_ZtjALI2WUnS1vK8PMev-yWbBu8ot4NNInunsKxkRz-nI2mRDmU3wFZfIyMaQjUDvZ9pLcmfpg9Xbqtp9D-7K2IVS1ZNYoFQiDbZm7HqkaL4BSz1do/s320/emptyreport.png" width="320" /></a></div>
Drag and drop a static text in the palette and place it on the title section. This will be our report title. Double click on it to change text and edit it to My Report.<br />
If the palette on the right is not present at default, you can open it by going to Window>IDE Tools>Palette.<br />
Your report should now look like this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZSem0MehnVZhSvosW4ZXFxOnnHToTLDr_DvwY2y_wz-Dk60mVscfHM-g8b6CKruTAZp4cvCwuNVAZGXR-DXaAe88xrnxlvPwEmO-UvEwsMiobfPh3jhGCLJO0nxHaO27bVi_JAwPhHwQ/s1600/statictext2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZSem0MehnVZhSvosW4ZXFxOnnHToTLDr_DvwY2y_wz-Dk60mVscfHM-g8b6CKruTAZp4cvCwuNVAZGXR-DXaAe88xrnxlvPwEmO-UvEwsMiobfPh3jhGCLJO0nxHaO27bVi_JAwPhHwQ/s320/statictext2.png" width="320" /></a></div>
<br />
We are going to add column headers for our report. drag and drop several static text objects and place them like this<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiotPTxQL8FQ6zjYyz5rDLr9yVzUS1oSN0Ax9HduhSp6B_izm28J2Xv6q4faQ4JCieu2VA2QsJMcBTglD3T9kA7_Q2cvhOg1NMlAnifHZUurlxAFtxzPrpV4Ot_goFpCGslx9BgWiuWTx0/s1600/statictext3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="161" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiotPTxQL8FQ6zjYyz5rDLr9yVzUS1oSN0Ax9HduhSp6B_izm28J2Xv6q4faQ4JCieu2VA2QsJMcBTglD3T9kA7_Q2cvhOg1NMlAnifHZUurlxAFtxzPrpV4Ot_goFpCGslx9BgWiuWTx0/s320/statictext3.png" width="320" /></a></div>
Edit all of them and the first should be name, second IdNumber and the other one category. Make sure that you place them inside the column headers section and shrink the section as shown in the image.<br />
<br />
in the details section, drag and drop several TextFields from the palette and arrange them like this.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikfV0mthN4yxwJKZaPY4OzTXpm_HIMrt6fxUHGm17P1CWYdWdyFvjknPPzPZSmIR3agziswst7uqyp8_zFaMW_4S7dGAfDF4ATToM2ZYEK0QfeTgvNBxaEx2-E2bkNLZ3OrEjv3ehWB5g/s1600/reportdesignsemi.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikfV0mthN4yxwJKZaPY4OzTXpm_HIMrt6fxUHGm17P1CWYdWdyFvjknPPzPZSmIR3agziswst7uqyp8_zFaMW_4S7dGAfDF4ATToM2ZYEK0QfeTgvNBxaEx2-E2bkNLZ3OrEjv3ehWB5g/s320/reportdesignsemi.png" width="320" /></a></div>
We are going to pass a list of employee object to The jasper report engine. The engine will extract information about the object using fields. we need to set this field. in the report inspector, Right click on Fields and click on add field. rename the added field by right clicking on it then rename.name it 'name' without quotes. do the same for the other two. Remember the field names should match those of the objects variables. <br />
<br />
Build the report by clicking here. If there are no errors, report should build successfully.<br />
<br />
Open the List.xhtml inside the employee folder, locate this line<br />
<p:commandButton id="deleteButton" icon="ui-icon-trash" value="#{bundle.Delete}" actionListener="#{employeeController.destroy}" update=":growl,datalist" disabled="#{empty employeeController.selected}"/> <br />
and below it add the following line <br />
<p:commandButton id="print" icon="ui-icon-print" value="Print" actionListener="#{employeeController.print()}" ajax="false"/><br />
<br />
inside the controller package, open the EmployeeController.java and add the following code just below the class<br />
<br />
public void print() throws IOException, JRException<br />
{<br />
JasperPrint jasperPrint;<br />
System.out.println("calling print");<br />
JRBeanCollectionDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(getItems());<br />
FacesContext facesContext = FacesContext.getCurrentInstance();<br />
String reportPath = facesContext.getExternalContext().getRealPath("/jasper/employeelist.jasper");<br />
Map params = new HashMap();<br />
jasperPrint = JasperFillManager.fillReport(reportPath, params, beanCollectionDataSource);<br />
HttpServletResponse httpServletResponse = (HttpServletResponse) facesContext.getExternalContext().getResponse();<br />
httpServletResponse.addHeader("Content-disposition", "attachment; filename=" + "all" + ".pdf");<br />
try (ServletOutputStream servletOutputStream = httpServletResponse.getOutputStream()) {<br />
JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);<br />
servletOutputStream.flush();<br />
}<br />
FacesContext.getCurrentInstance().responseComplete();<br />
}<br />
<br />
open the porm.xml located in the Project Files folder.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj23lX3t2qQU5c7L2e3_WGnrDV58AOU8WGA1UYctAGOh8VZ4RD6sG_KTVK9FLeG5EHf4px2rAKaH3sJ2oKSYY5BweLqaV7R7P8Uz2uNL4CWcgsLfkDFFEIXBB5DvLwOWzye4_BK0xiMSQQ/s1600/resourcesopen1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj23lX3t2qQU5c7L2e3_WGnrDV58AOU8WGA1UYctAGOh8VZ4RD6sG_KTVK9FLeG5EHf4px2rAKaH3sJ2oKSYY5BweLqaV7R7P8Uz2uNL4CWcgsLfkDFFEIXBB5DvLwOWzye4_BK0xiMSQQ/s1600/resourcesopen1.png" /></a></div>
<br />
Locate the </dependacies> closing tag and add the following code just above it.<br />
<br />
<dependency><br />
<groupId>net.sf.jasperreports</groupId><br />
<artifactId>jasperreports</artifactId><br />
<version>6.1.0</version><br />
</dependency><br />
<br />
you should have something similar to this.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu4gKN0A0Bw2XStmYl7G85h95YC8sYO7zNBLS16QqVmJvF0Chs50gUxK1psdGYryiHYwBAXYA2ZtlC5CHewms397_pvhJpHkJ5ii4W1C2-FGBZNluen5_RgYKFjwo-2norZXOuHIkrVJQ/s1600/pormadded.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu4gKN0A0Bw2XStmYl7G85h95YC8sYO7zNBLS16QqVmJvF0Chs50gUxK1psdGYryiHYwBAXYA2ZtlC5CHewms397_pvhJpHkJ5ii4W1C2-FGBZNluen5_RgYKFjwo-2norZXOuHIkrVJQ/s320/pormadded.png" width="320" /></a></div>
<br />
This line adds jasper report library into our project. <br />
build the project again and run. <br />
When you run the project, you should see a report generated when you click on the print button. The complete project with resources can be downloaded from <a href="https://www.dropbox.com/s/mg9r3lce4xychkd/Employee.7z?dl=0" target="_blank">here</a><br />
<br />
<br />
<br />
<br />Please be careful with NCBA Asset finance.http://www.blogger.com/profile/10733977270923746953noreply@blogger.com1tag:blogger.com,1999:blog-6612973132026573328.post-78072542380518897562015-07-13T06:06:00.001-07:002015-07-14T11:13:35.010-07:00Jasper report with netbeans IDE, mysql,JavaEE, Primefaces. part 3Hello Guys.<br />
<br />
This is part 3 of the tutorial series. In this part, we will create a A web application which can perform crud(create, read, update, delete) application to our database. We will not do much of coding. Netbeans will generate a lot of code for us..<br />
1). Setting up the database. We are going to use a very simple database with just two tables.<br />
The structure of our database will looks like this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX1z7MG2XGiwFwH7dEIsJcdbWzdGq6G0hxcT8BVbf9zbB9ZKEwgRRqPq3Ohkik9nP-gOqa_Kjjzdobu9FzC9H9_53eYelxO71UXemf43EaGbw8MhakWPOPnkjxh4RBNVR4G3vpgZv5v28/s1600/database.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="130" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX1z7MG2XGiwFwH7dEIsJcdbWzdGq6G0hxcT8BVbf9zbB9ZKEwgRRqPq3Ohkik9nP-gOqa_Kjjzdobu9FzC9H9_53eYelxO71UXemf43EaGbw8MhakWPOPnkjxh4RBNVR4G3vpgZv5v28/s320/database.png" width="320" /></a></div>
<br />
<br />
You can create it manually or you can import using <a href="https://www.dropbox.com/s/4omq21t8vlnhefz/employee.sql?dl=0" target="_blank">this</a> sql script.<br />
<br />
Once the database is set, you need to go back to netbeans and under the services tab, expand MySQL server at localhost, and you will see a list of all the databases in your mysql.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkTuHnVv4-HcCpAsNIE6bZ7LhG9iEQ9WVozVEgI-k2ghpzLVCvBlFQIrVnIdQOZDI9ces34qitWSRkL5Yh_FpjHjW23YfGXqbzRBbfdUlxntEaybMaur6WYi6QtAPPCG5nPY3S9WaKfSk/s1600/databaselisting.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkTuHnVv4-HcCpAsNIE6bZ7LhG9iEQ9WVozVEgI-k2ghpzLVCvBlFQIrVnIdQOZDI9ces34qitWSRkL5Yh_FpjHjW23YfGXqbzRBbfdUlxntEaybMaur6WYi6QtAPPCG5nPY3S9WaKfSk/s320/databaselisting.png" width="254" /></a></div>
<br />
locate the database with the name employee. Incase you dont see it,
right click on MySQl server at localhost and select refresh.Once its
available, right click on it and select connect. Netbeans will create a
connection to that database as shown here. <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8xAT0ECUeZ5KiTSqmMzdDJcPIY_Eq1gpVpzdKLO8YiiwVn_DPkpGov_cfvzEqNMJQWSTMZ4K7kXz7mDeYIbCEr-MGV4yVRGQJXpIK-PKvbiyOZmXxSt7O_fO5k8MCS2uNC0gQFYi7XJ8/s1600/conncetion.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="30" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8xAT0ECUeZ5KiTSqmMzdDJcPIY_Eq1gpVpzdKLO8YiiwVn_DPkpGov_cfvzEqNMJQWSTMZ4K7kXz7mDeYIbCEr-MGV4yVRGQJXpIK-PKvbiyOZmXxSt7O_fO5k8MCS2uNC0gQFYi7XJ8/s320/conncetion.png" width="320" /></a></div>
<br />
<br />
<br />
2.Creating a web application with crud operations.<br />
Inside netbeans, go to File>New project under category select Maven>Web Application give it the name of your choice. Leave all the other details default.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4CnIB527awlk_EzvLZKW-oWOW88UipwaKEFFUC14gVNIwvOY_w5Yju2-dft50DXXsinP4LxdaW-70_M746nz1Bzgy33PlWv5mvPNS8al6KE-fIqNLNVy2S5hyphenhyphenA7OuqepkZEgQhfFyGPM/s1600/newproject.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4CnIB527awlk_EzvLZKW-oWOW88UipwaKEFFUC14gVNIwvOY_w5Yju2-dft50DXXsinP4LxdaW-70_M746nz1Bzgy33PlWv5mvPNS8al6KE-fIqNLNVy2S5hyphenhyphenA7OuqepkZEgQhfFyGPM/s320/newproject.png" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjukMdaA6a0ldp0eJAxjeHxCPJXKblcuxAv-Wh1MJpvGt877nmfMLGVFVfQd1ABmVUKmdSyt3hwrGfRCFdfocXpGTZDYPL2af0VvRBG2lqaO09Bnfpgrssdk3qhCD41ZGFC0ENzcstslMI/s1600/projectname.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="220" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjukMdaA6a0ldp0eJAxjeHxCPJXKblcuxAv-Wh1MJpvGt877nmfMLGVFVfQd1ABmVUKmdSyt3hwrGfRCFdfocXpGTZDYPL2af0VvRBG2lqaO09Bnfpgrssdk3qhCD41ZGFC0ENzcstslMI/s320/projectname.png" width="320" /></a></div>
<br />
<br />
Right click on the new project, go to properties.<br />
<br />
Go to frameworks. Click add, select Java Server Faces <br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsvGC4wxMwQRy-o_u4lB2smYAbWxgi5Hq051y9YolYMH98QKFJVQhHxkCWRHTYWeCN6no_86OpzGzjBPya7jgDeP7vDQRilswnUfTgNtroMOGl_fdFqC3xlxBlTVxtsZsG7X_zCa2Ipks/s1600/addingframework.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsvGC4wxMwQRy-o_u4lB2smYAbWxgi5Hq051y9YolYMH98QKFJVQhHxkCWRHTYWeCN6no_86OpzGzjBPya7jgDeP7vDQRilswnUfTgNtroMOGl_fdFqC3xlxBlTVxtsZsG7X_zCa2Ipks/s320/addingframework.png" width="320" /></a></div>
<br />
In the Java Server Faces configuration, in the component tab,select primefaces and click ok.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRj-rU61wCWYxKVyOKo4kaVkrPlRZWgFdlBlQfC7Rv_KdxRIBHE1Ai1WvFr53N5QZgwokCtnw0VBMvjvv_hGY-ODu9b_m0T4qKc4OYDVF11ZO1KfjodqhMCzlzOMe3K-EDo8gFWimLW5I/s1600/addedprimefaces.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRj-rU61wCWYxKVyOKo4kaVkrPlRZWgFdlBlQfC7Rv_KdxRIBHE1Ai1WvFr53N5QZgwokCtnw0VBMvjvv_hGY-ODu9b_m0T4qKc4OYDVF11ZO1KfjodqhMCzlzOMe3K-EDo8gFWimLW5I/s320/addedprimefaces.png" width="320" /></a></div>
<br />
Clean build the project. Maven will download all the required libraries for you. Just sit back and relax. When the building process completes, run your project. it should open on your browser and show something like this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvaMFxSjWyuIWqMI1l-nxD5uibzW6j65rX7fKsjQ6tBEfwi7KaVn6mVMdmUXDbTyxpPBUIkJ0nqUJeheC5lT8IJ5YPGKBAL-MwP9yx6yCdVwm1WbXDtPpKx7KN9ZLrQnYT_E7qsQidXK8/s1600/welcomeprimefaces.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvaMFxSjWyuIWqMI1l-nxD5uibzW6j65rX7fKsjQ6tBEfwi7KaVn6mVMdmUXDbTyxpPBUIkJ0nqUJeheC5lT8IJ5YPGKBAL-MwP9yx6yCdVwm1WbXDtPpKx7KN9ZLrQnYT_E7qsQidXK8/s1600/welcomeprimefaces.png" /></a></div>
<br />
<br />
The next part is to link our project to our database. Right click on the project you have created, go to new>Entity Classes From Database. On the Data Source option, click on the drop down menu,scroll and pick the last option in the menu which is new data source.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGYpOvpx5wNKVzbs1kGDaL0IZsh-4boWsBIHb9-e_uws4b_ZCWwkOxa78kqtHXfjvlFMXpukhPWRz7l8enrtW_g7o8D5nptbBdg8xKztpTlyCEJu_6OU3Rr_hnDewG9-0u2giNBeziw8Q/s1600/createconnection.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGYpOvpx5wNKVzbs1kGDaL0IZsh-4boWsBIHb9-e_uws4b_ZCWwkOxa78kqtHXfjvlFMXpukhPWRz7l8enrtW_g7o8D5nptbBdg8xKztpTlyCEJu_6OU3Rr_hnDewG9-0u2giNBeziw8Q/s320/createconnection.png" width="320" /></a></div>
<br />
On the JNDI Name call it jdbc/employee and in the Database Connection option, select the new connection the was added by netbeans during step *****. All the table in that database will appear in the left panel.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3vhTL97P5fYW5zYyenoqI4gcTnz4QFpOdVEzuZPwwf_LvRx5ingTxTZRMKjMyGYUSKJ9RS0DQ5wnqH60MgIlt4V6279_4za3zRc2iSDqcTXjZSXfVKqbCo6qj0fHzEjMtG_fY8B9KmgA/s1600/datbasetables.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3vhTL97P5fYW5zYyenoqI4gcTnz4QFpOdVEzuZPwwf_LvRx5ingTxTZRMKjMyGYUSKJ9RS0DQ5wnqH60MgIlt4V6279_4za3zRc2iSDqcTXjZSXfVKqbCo6qj0fHzEjMtG_fY8B9KmgA/s320/datbasetables.png" width="320" /></a></div>
<br />
At the center of the two panels, click on add all and click next.All tables will be shown now on the right panel.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcAvwdcZBKJOr5GW82Xfv53W0LU16x6hBRQ-mTqgaSOMldVGuTZfi2Ma0Md1mtamhnktzS1BgojoG3rOWNA9ArcJ5tW587KNDbxhpSL_hPObDlxlqfU4YCd9iG4zPBcP3NkjUzPCPXoUk/s1600/datbasetablesadde.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="226" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcAvwdcZBKJOr5GW82Xfv53W0LU16x6hBRQ-mTqgaSOMldVGuTZfi2Ma0Md1mtamhnktzS1BgojoG3rOWNA9ArcJ5tW587KNDbxhpSL_hPObDlxlqfU4YCd9iG4zPBcP3NkjUzPCPXoUk/s320/datbasetablesadde.png" width="320" /></a></div>
<br />
<br />
Click next.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh887bZVRXEHOnnunDJ9ANZ3jU5tJzd48WGOez45fVUPPI6vhGN1nEsmt3qQ6erBahp4fmt2tzdUrDm6Nb0NhNGnfhZ66MxwQPfGpXItuXahMN1ksPXto-yDRCgdHDI0K7f4GBEGKuvh0g/s1600/package.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh887bZVRXEHOnnunDJ9ANZ3jU5tJzd48WGOez45fVUPPI6vhGN1nEsmt3qQ6erBahp4fmt2tzdUrDm6Nb0NhNGnfhZ66MxwQPfGpXItuXahMN1ksPXto-yDRCgdHDI0K7f4GBEGKuvh0g/s320/package.png" width="320" /></a></div>
<br />
Enter 'entities' as the package name.Leave everything default and click finish.<br />
Right on the project again and select JSF From Entity Classes.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi56GC_fdb4721Vs-wd09Mgm1O5ZnSrggSDzRuaXQCeeRx6-1rr6S76B3ovvqhEnSYHc9CS8-0FYBgN8F4uR1vh4jQqVRdLnfYmxJSPFnWvEIXuPNriNfcUEfb6CYdJhE5Qe7XGcUKFCDs/s1600/createjsf.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="216" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi56GC_fdb4721Vs-wd09Mgm1O5ZnSrggSDzRuaXQCeeRx6-1rr6S76B3ovvqhEnSYHc9CS8-0FYBgN8F4uR1vh4jQqVRdLnfYmxJSPFnWvEIXuPNriNfcUEfb6CYdJhE5Qe7XGcUKFCDs/s320/createjsf.png" width="320" /></a></div>
<br />
In the next window, click add all, click next, enter facades as the session bean package name and controllers as the JSF Classes package.On the choose templates, click on the drop down and select primefaces.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL8E_G606mmj1GYYIXymQJiT9saxAoG80xwU93L_DhfjP3TATGnWxFKZfHrw9VDTai3K0O2u8I5wUgwI6qx8kQz100BA0A8gLXfBfaGB5pZoUdhVegI3Hr_8LyTYItoPEtJgbNLSg2dME/s1600/jsfcreationfinal.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjL8E_G606mmj1GYYIXymQJiT9saxAoG80xwU93L_DhfjP3TATGnWxFKZfHrw9VDTai3K0O2u8I5wUgwI6qx8kQz100BA0A8gLXfBfaGB5pZoUdhVegI3Hr_8LyTYItoPEtJgbNLSg2dME/s320/jsfcreationfinal.png" width="320" /></a></div>
<br />
<br />
Click on finish, clean build and run the project again. If all goes well, you should see something like this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUExjZpUZTShDREaQFsK1V32tlD3YuxLrtdIfMvJrioF-nVvPcu4FnTOCHfL0ykpmGNPqi1xTnNltjKMUNW8b8C_Eol2mXyaEWbBm0ktolL9L4LixyEJ_yWqMwXxGPkMUk-IB7YnR8eJQ/s1600/hello.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUExjZpUZTShDREaQFsK1V32tlD3YuxLrtdIfMvJrioF-nVvPcu4FnTOCHfL0ykpmGNPqi1xTnNltjKMUNW8b8C_Eol2mXyaEWbBm0ktolL9L4LixyEJ_yWqMwXxGPkMUk-IB7YnR8eJQ/s1600/hello.png" /></a></div>
Sometimes glassfish will give the following error.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_TnZze867FhCVPIx7xGhyf8nIq5YKIustz76bdFPsURFm_N1MQoC7cXIUvypRxORx7uW5A9cw1H3x1JDEs3nnpmzT_0gPl6C1Np61Ua_RSAQTXrQtzFVSMsS51m9XitgPnIhl_MssFS8/s1600/jdbcerror.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="81" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_TnZze867FhCVPIx7xGhyf8nIq5YKIustz76bdFPsURFm_N1MQoC7cXIUvypRxORx7uW5A9cw1H3x1JDEs3nnpmzT_0gPl6C1Np61Ua_RSAQTXrQtzFVSMsS51m9XitgPnIhl_MssFS8/s320/jdbcerror.png" width="320" /></a></div>
<br />
<br />
There are two solutions for this but I will discuss the easiest one.<br />
<br />
Go to other sources in your project as per the image below.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihd7cEaTUvTXxFPTcy75-AtD0HA0pIns9vtBP1msw9gqbt1InEtVMCT1ByZmc-rbgfssIwFkDHqEYG194Tef51h83B23vfC5O61hZQcgSJ4fZQCZt5YUZs2qDxvYSARXM4mv80QhqBWOU/s1600/resourcesopen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihd7cEaTUvTXxFPTcy75-AtD0HA0pIns9vtBP1msw9gqbt1InEtVMCT1ByZmc-rbgfssIwFkDHqEYG194Tef51h83B23vfC5O61hZQcgSJ4fZQCZt5YUZs2qDxvYSARXM4mv80QhqBWOU/s1600/resourcesopen.png" /></a></div>
<br />
<br />
The glassfish-resources.xml in the setup folder. Select all the content inside the <resources> content to be copied.</resources><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYj8u2RTFRZiMarEhb3zRvGlb7stEfDkEbOk2XUbT6Pxjsxk43ra4hIle3NuPlyDtjEIMnVU23sMNg4AaVMGR0aa0_nMz0YvMiocA_oALcPWEg7VRPPqQTX4FUHKdsbx1JHGfHJljiElY/s1600/resources+copy.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="70" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYj8u2RTFRZiMarEhb3zRvGlb7stEfDkEbOk2XUbT6Pxjsxk43ra4hIle3NuPlyDtjEIMnVU23sMNg4AaVMGR0aa0_nMz0YvMiocA_oALcPWEg7VRPPqQTX4FUHKdsbx1JHGfHJljiElY/s320/resources+copy.png" width="320" /></a></div>
<br />
Open the domain.xml file located here glassfishhome/domains/domain1/config/domain.xml<br />
Mine looks like this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk5YNElcAAxBqaUuwseLz0rJEkw2scima63l4EIbH6FKzouV0z0KzPIg8Xo9O0O7BkmRqbH9VEn6kgjsl9TRdYQe1pIl_jAEoZmlWqmioYEdzl12l8jnYzIe9bb5tNlAEV_ryRfj-dLgA/s1600/domainxmllocation.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="95" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk5YNElcAAxBqaUuwseLz0rJEkw2scima63l4EIbH6FKzouV0z0KzPIg8Xo9O0O7BkmRqbH9VEn6kgjsl9TRdYQe1pIl_jAEoZmlWqmioYEdzl12l8jnYzIe9bb5tNlAEV_ryRfj-dLgA/s320/domainxmllocation.png" width="320" /></a></div>
<br />
Search for the <resources> opening tag.press enter immediately after the <resources> tag.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOk-UY_fzz3A2clGQ2hHN9geFWa6NZxkBO77uiLJE2aa5TDwNXRn8JPc-1p7-HmKoqgfiilyXsjv4rU9z777G3nMEZIibRNOxfII1ufKxmePiLAa5VTvvylMEwirnTmdLT7vA7u_tX7MQ/s1600/resoucestaglocate.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOk-UY_fzz3A2clGQ2hHN9geFWa6NZxkBO77uiLJE2aa5TDwNXRn8JPc-1p7-HmKoqgfiilyXsjv4rU9z777G3nMEZIibRNOxfII1ufKxmePiLAa5VTvvylMEwirnTmdLT7vA7u_tX7MQ/s1600/resoucestaglocate.png" /></a></div>
<br />
Paste the content there.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJm89-uchb4P8dXK7G1PFJDQXNaF3BRko5If0G02vL102lqQcnmI5vfwFpx5kkkVORjEnLEdWdbno-H3oFX1bPorLeOo32WSXcVAcRWPgyfGKPbOAoMdXzDYKTaNthUdD2ct2dxm4MXhg/s1600/resoucespastehere.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="232" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJm89-uchb4P8dXK7G1PFJDQXNaF3BRko5If0G02vL102lqQcnmI5vfwFpx5kkkVORjEnLEdWdbno-H3oFX1bPorLeOo32WSXcVAcRWPgyfGKPbOAoMdXzDYKTaNthUdD2ct2dxm4MXhg/s320/resoucespastehere.png" width="320" /></a></div>
<br />
Save the file and restart your glassfish(go to the services tab>Servers right click on the glassfissh and click restart). Your app should now run without error.<br />
Click on Show All Employee Items.Now you can add, edit view and delete data from our database.<br />
We will do some customization.<br />
Inside the entities package, open employee.java and add the following code<br />
public String getCategory()<br />
{<br />
return this.categoryId.getCategoryName();<br />
}<br />
This method will give the string representation of the employee category name.<br />
<br />
in the web pages folder, open List.xhtml which is inside the employee sub-folder, Locate where you have this line of code <h:outputText value="#{item.categoryId.id}"/> and change it to <h:outputText value="#{item.category}"/>. run the application again and when you go to all employess, you will notice that the department name is now the actual name not the integer id.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2AzuwXP0KgDyj3WPh2xwT1j3DNzbBpTFKLt-3bUKUMO8mzunz6f4sd4n_BXzcXvDNGo-kuzrA-Be5HrGZGvjZ63wayy2uKHImaELiMT4xff7DnOA3RZJEElwA8nu2bks5sU9S0Wh0JQU/s1600/listxhtml2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="44" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2AzuwXP0KgDyj3WPh2xwT1j3DNzbBpTFKLt-3bUKUMO8mzunz6f4sd4n_BXzcXvDNGo-kuzrA-Be5HrGZGvjZ63wayy2uKHImaELiMT4xff7DnOA3RZJEElwA8nu2bks5sU9S0Wh0JQU/s320/listxhtml2.png" width="320" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
In the same List.xhtml, add the following lines inside the <p:dataTable> tag.<br />
rowIndexVar="rowIndex"<br />
paginatorPosition="bottom"<br />
the final tag should look like this.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfFouNvgXE2n3BfsLtqOp-T_fR-Ggaj_8hfXooAXuP5N8PFxsk_uBmPF4lIIvYDIpoSszhrIelP2p01ePwlTmNK-P5-G12i1KPlZgqFKDp0ipTik6XvJmcjg9-NmW0mlalXmBK0sa62nU/s1600/listxhtml.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="201" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfFouNvgXE2n3BfsLtqOp-T_fR-Ggaj_8hfXooAXuP5N8PFxsk_uBmPF4lIIvYDIpoSszhrIelP2p01ePwlTmNK-P5-G12i1KPlZgqFKDp0ipTik6XvJmcjg9-NmW0mlalXmBK0sa62nU/s320/listxhtml.png" width="320" /></a></div>
<br />
<br />
delete the first dataTable column that displays item,id and replace it with<br />
<p:column style="width:5%"><br />
<f:facet name="header"><br />
<h:outputText value="No."/><br />
</f:facet><br />
<h:outputText value="#{rowIndex+1}"/><br />
</p:column><br />
<br />
Check image above for hint. <br />
Run the app again. you will notice that the table now has a counter for all item without exposing the id of the employee item as stored in the database.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_OIoiPonX4YF5lxbmp9xfGztDQVhciGsV6TXETIXC-fS_OJvI5hIHOO6JmAAsGLsZRpVQUnLAB1NP75ZAfkuKnoV1QR4WjVJVjypEeAQKIIfvUYosgaE0xNynd-LJulSQAtjqCRxupf8/s1600/listxhtml1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="40" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_OIoiPonX4YF5lxbmp9xfGztDQVhciGsV6TXETIXC-fS_OJvI5hIHOO6JmAAsGLsZRpVQUnLAB1NP75ZAfkuKnoV1QR4WjVJVjypEeAQKIIfvUYosgaE0xNynd-LJulSQAtjqCRxupf8/s320/listxhtml1.png" width="320" /></a></div>
<br />
When you click on create employee button, you will see something like this<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBqxgp08u6RhaF5XUr28RYrLGqv97ayECYassfuOrHIdGgz1JEp1pLnSOv4ez_O_i-H0cWigoJ3kXiLeMQLruFIwid6vA65L4BFr82zcrbAWy_h3nyaIMpvUc-bbLKi-cHmd6kuKh-5JQ/s1600/createfake.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="273" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBqxgp08u6RhaF5XUr28RYrLGqv97ayECYassfuOrHIdGgz1JEp1pLnSOv4ez_O_i-H0cWigoJ3kXiLeMQLruFIwid6vA65L4BFr82zcrbAWy_h3nyaIMpvUc-bbLKi-cHmd6kuKh-5JQ/s320/createfake.png" width="320" /></a></div>
<br />
while we expect something like this.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4vvviTPLjjdkdXD6cSDygiV3z1RgIvgeySmz-2hREt6ClmYk5dH8Yb9cBAiix34FYKbjrpeSb_IrPix45h_oah70f-9XUcgopDtN41kAewr95QSHb5ZgUuZUB4kYLYFpLdkhHCuczR6E/s1600/createfinal.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4vvviTPLjjdkdXD6cSDygiV3z1RgIvgeySmz-2hREt6ClmYk5dH8Yb9cBAiix34FYKbjrpeSb_IrPix45h_oah70f-9XUcgopDtN41kAewr95QSHb5ZgUuZUB4kYLYFpLdkhHCuczR6E/s320/createfinal.png" width="320" /></a></div>
<br />
To fix that, locate where you have this lines of code<br />
var="categoryIdItem" itemLabel="#{categoryIdItem}"<br />
and change it to var="categoryIdItem" itemLabel="#{categoryIdItem.categoryName}"<br />
do the same for the edit.xhtml. test the app again.<br />
I now assume that you know what to do with the view.xhtml.<br />
<br />
In the <a href="http://androidtesstwo.blogspot.com/2015/07/jasper-report-with-netbeans-ide_46.html" target="_blank">next</a> post, we will design our report and update our list>xhtml so that we can have a button to trigger the report creation. Please Let me know if there are any problems you are facing. Thanks.Please be careful with NCBA Asset finance.http://www.blogger.com/profile/10733977270923746953noreply@blogger.com0tag:blogger.com,1999:blog-6612973132026573328.post-90925033998362930112015-07-13T05:05:00.003-07:002015-07-14T08:49:02.860-07:00Jasper report with netbeans IDE, mysql,JavaEE, Primefaces. part 2 Hello guys. In this post I will show you how to set up the netbeans IDE in order to complete our task which is to create a report using jasper report engine. Details can be found <a href="http://androidtesstwo.blogspot.com/2015/07/jasper-report-with-netbeans-ide.html" target="_blank">here</a><br />
<br />
1.Setting up netbeans. The installation for netbeans is fairly an easy task. Am not going to show you how to do that but briefly I will show you how to link netbeans with mysql and glassfish. In case your netbeans is set already, you can skip to <a href="http://androidtesstwo.blogspot.com/2015/07/jasper-report-with-netbeans-ide_74.html" target="_blank">part 3</a> of this post.<br />
<br />
a). Adding mysql support. Locate the service tab as indicated in the image below.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnyyzkljjlJerISyu1KcW2AuUyPYH7HrZ3zSGcTU5dAeX9WHRduQCoye4XRuln2DVZJH17xqKNNCzY06BrbwjZ_VoWgw_GnwVaYIB7mmVRe2CinzGJo7gInTLiGBvO3VkKfD2aDqROlCs/s1600/job10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnyyzkljjlJerISyu1KcW2AuUyPYH7HrZ3zSGcTU5dAeX9WHRduQCoye4XRuln2DVZJH17xqKNNCzY06BrbwjZ_VoWgw_GnwVaYIB7mmVRe2CinzGJo7gInTLiGBvO3VkKfD2aDqROlCs/s320/job10.png" width="320" /></a></div>
Right click on Databases and select New connection. On the driver option, select MySQL (Connector/j driver). Press next and on the next dialog, ensure that the details are accurate.Enter the correct username and password. In case you have problems, it could be that you have not set mysql password for the username entered. <br />
<br />
b). Adding glassfish server. If you downloaded the netbeans for JavaEE developers, glassfish will automatically be added when you install netbeans. You can skip this to <a href="http://androidtesstwo.blogspot.com/2015/07/jasper-report-with-netbeans-ide_74.html" target="_blank">here</a>.<br />
<br />
In case your netbeans doesn't have glassfish server added, under the services tab, right click on server, select add server. the server option select glassfish.On the installation location, search the location you have stored your glassfish server.the other steps are very straightforward.<br />
<br />
In the next post. We will prepare the database and create a crud application.<br />
<br />
<a href="http://androidtesstwo.blogspot.com/2015/07/jasper-report-with-netbeans-ide_74.html" target="_blank">Part 3</a>Please be careful with NCBA Asset finance.http://www.blogger.com/profile/10733977270923746953noreply@blogger.com0tag:blogger.com,1999:blog-6612973132026573328.post-9805230923761359852015-07-13T04:16:00.001-07:002015-07-17T05:02:03.070-07:00Jasper report with netbeans IDE, mysql,JavaEE, Primefaces. part 1<div class='fln-affiliate' data-username='solokingjec11' data-style='' data-qts='//t.flnaffiliate.com/' data-type='banner' data-theme='faces' data-size='336x280' ></div>
<script type='text/javascript'>(function(d) {
var po = d.createElement('script');
po.type = 'text/javascript'; po.async = true; po.src = '//static.flnaffiliate.com/build/js/affiliate-sdk.js';
var s = d.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})(document);</script>
Hello guys.<br />
<br />
In this post, am going to show you how to make a report using <a href="http://community.jaspersoft.com/project/jasperreports-library" target="_blank">jasper report library</a>. we will begin by creating a simple crud java web application using primefaces. This application will fetch and post data from and to a database engine. The data will then be exported as a .pdf using the jasper report engine.<br />
<br />
Prerequisites.<br />
1. Background knowledge of java, sql. <br />
<br />
Requirements.<br />
1. Netbeans IDE All-version . Can be downloaded from <a href="http://https//netbeans.org/downloads/">here</a>. Make sure that you have downloaded netbeans with JavaEE support as there are several options for netbeans downloads.see image below<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjS6u586luVuBhMKIRK9oQSnD4W4OkTLyo_7VRaw1JNK7qB5nulLz2sCpWbxGk_et0gYXK8C1EWaCC5LSIIRlQGPcxIQ2b9vCgkSxZSqxE9ycrZgfoO_sYfxJMnbQk68PdLMvV1pj4mkto/s1600/job9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="156" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjS6u586luVuBhMKIRK9oQSnD4W4OkTLyo_7VRaw1JNK7qB5nulLz2sCpWbxGk_et0gYXK8C1EWaCC5LSIIRlQGPcxIQ2b9vCgkSxZSqxE9ycrZgfoO_sYfxJMnbQk68PdLMvV1pj4mkto/s400/job9.png" width="400" /></a></div>
<br />
<br />
2. Database engine. You can use the database engine of your choice but for this tutorial, I will be using mysql under lampp. For windows its xamp you can get it from <a href="https://www.apachefriends.org/download.html">here</a><br />
<br />
3. Jasper report netbeans plugin. We will design our report inside the Netbeans IDE for simplicity.<br />
Use can use Jasper studio as a standalone designer.You can download jasper studio from <a href="http://community.jaspersoft.com/project/jaspersoft-studio/releases">here.</a><br />
In this example, we are going to use iReport installed in netbeans as a plugin.The plugin can be found here <a href="http://plugins.netbeans.org/plugin/4425/ireport">here</a><br />
Details on how to install it on netbeans can be found <a href="http://wiki.netbeans.org/InstallingAPlugin">here</a><br />
<br />
4. Internet Connection. Maven requires a good connection to the internet in order to download required libraries for your project.ensure that you have a reliable internet connection.<br />
6. MySQL Connector. This is a java library that helps you to connect a java application to a MySQL database engine. It can be found <a href="http://dev.mysql.com/downloads/connector/j">here</a><br />
. Once you have downloaded the zip file, extract the .jar file and paste it in this:- location /glassfishhome/glassfish/lib/. In case your glass-fish server is running, you must restart it for the changes to take effect.<br />
7. You patience and ability to learn. Programming is something you will learn in your life time. Take it easy and have the spirit of a diehard.<br />
<br />
Our final report will be like this.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIgQw2Ui_06ah6GK70TGTu2HHMWMUFlzviqCvpH6Oqu630n2_rlBPmD3fezoD80bJUpoZ74gJbsVZN2-iXzAGTfClecPxLvTO2ErEiVX98TynffLE6q7_f2M4NdNK0APcNqs5c6Y-zpFE/s1600/job13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIgQw2Ui_06ah6GK70TGTu2HHMWMUFlzviqCvpH6Oqu630n2_rlBPmD3fezoD80bJUpoZ74gJbsVZN2-iXzAGTfClecPxLvTO2ErEiVX98TynffLE6q7_f2M4NdNK0APcNqs5c6Y-zpFE/s400/job13.png" width="400" /></a></div>
<br />
All materials used in this tutorial can be downloaded from <a href="https://www.dropbox.com/s/mg9r3lce4xychkd/Employee.7z?dl=0" target="_blank">here</a> <br />
<br />
click <a href="http://androidtesstwo.blogspot.com/2015/07/jasper-report-with-netbeans-ide_13.html" target="_blank">here</a> for the part twoPlease be careful with NCBA Asset finance.http://www.blogger.com/profile/10733977270923746953noreply@blogger.com1tag:blogger.com,1999:blog-6612973132026573328.post-79769883647673615012014-03-18T07:26:00.000-07:002015-07-31T22:05:08.423-07:00Making Android OCR app using tess-two v3.03 library Without ndk, ant, cygwin and setting environment variables..
<div class='fln-affiliate' data-username='solokingjec11' data-style='' data-qts='//t.flnaffiliate.com/' data-type='banner' data-theme='faces' data-size='336x280' ></div>
<script type='text/javascript'>(function(d) {
var po = d.createElement('script');
po.type = 'text/javascript'; po.async = true; po.src = '//static.flnaffiliate.com/build/js/affiliate-sdk.js';
var s = d.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})(document);</script>
In this post, I will show you how to make an android app that will recognize text from an image using the tess-two library.<br />
<br />
You will not need to download android ndk, cygwin and ant. You will also not need to set environment variables. <br />
<br />
Requirements:<br />
<br />
<ol>
<li>Eclipse or any other IDE that has been configured for android development. </li>
</ol>
You will not need android ndk to build the tess-two library because I have already done that for you.<br />
<br />
Step 1.<br />
Download the pre-built tess-two library as .7za <a href="https://www.dropbox.com/s/7immbk4ibfb2eo8/tess-two_library.7z?dl=0"> here</a> and extract the tess-two
folder to any location. NB/ Do not extract into your workspace!!!!!<br />
<br />
Step 2.<br />
Download Simple-Android-OCR-master project from <a href="https://github.com/GautamGupta/Simple-Android-OCR" target="_blank"> here</a> and extract to the same location as the tess-two library.<br />
<br />
Step 3.<br />
Import the two projects into the eclipse workspace as shown below. <br />
go to File>Import>Existing android code into workspace>Root Folder: Browse. Select the folder that contains the two projects.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0J7GPTG8KiDaGeTjR8PoULotbSXaf61YU7m2Eq7KerX9QQEzvz2A70NPH_o7MI1nFerjBBc8lu4bLcTCmy8sm15IDotWVQ2UJNU-AhFpYV8d_96T7w5vqK07HEvX6vS5dRtekPgPRkME/s1600/import.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="355" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0J7GPTG8KiDaGeTjR8PoULotbSXaf61YU7m2Eq7KerX9QQEzvz2A70NPH_o7MI1nFerjBBc8lu4bLcTCmy8sm15IDotWVQ2UJNU-AhFpYV8d_96T7w5vqK07HEvX6vS5dRtekPgPRkME/s1600/import.png" width="400" /></a></div>
Check the two projects and also check Copy projects into workspace.<br />
You may encounter errors in-case you extracted them in you workspace.<br />
<br />
Click Finish.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZcP3rSHP2mjl4KibHZMlG1o0LrRsEvDfpAhMDnQ56OyaJkXMZ9T887LNtdAxc3eLFS-wyIuxh84rtEs_ixmUnaCTgavMfZN84DS9XXbOIel-fyI6fxg1aytXin0H7Q-19lK9NEb8pSho/s1600/import1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZcP3rSHP2mjl4KibHZMlG1o0LrRsEvDfpAhMDnQ56OyaJkXMZ9T887LNtdAxc3eLFS-wyIuxh84rtEs_ixmUnaCTgavMfZN84DS9XXbOIel-fyI6fxg1aytXin0H7Q-19lK9NEb8pSho/s1600/import1.png" width="400" /></a></div>
<br />
<br />
At this time, you should be able to run the Simple-Android-OCR-master project.In case you have errors, don’t panic.continue reading.<br />
<br />
You can import each project at a time in case you had extracted in different locations.<br />
<br />
<br />
Step 4. Mark the tess-two project as a library if its not marked already.<br />
Right click>properties>Android>Check is library.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcOkOpiTHaBT8nmGtRAXtVFegit6pS7JOLrFeZ3ZjZOBQlxGgUrbGzb698GzjaaNYnplC1VRHk4FNF8qga4gIXMaAOoKkonEafJ3k0Y8lsufbRTvLgqZ8YXou5H-3-3Zo9fkarbnBMNSg/s1600/markaslibraryproject.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcOkOpiTHaBT8nmGtRAXtVFegit6pS7JOLrFeZ3ZjZOBQlxGgUrbGzb698GzjaaNYnplC1VRHk4FNF8qga4gIXMaAOoKkonEafJ3k0Y8lsufbRTvLgqZ8YXou5H-3-3Zo9fkarbnBMNSg/s1600/markaslibraryproject.png" width="400" /></a></div>
<br />
<br />
Step 5. Reference the tess-two project in the other project.<br />
Right click project >Properties>Android>Add, select tess-two.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYjVMeD3GPA-qwFRuTSVYBrzJuGO6TkiWCBV3w336zHYoHzIJpG9M75updscq0dijYK3fdYCsiDxm3vDcWmc967eR0jbyvcxpSPA-0i32740c2fFk5IZR9YjPRNfGp2wfzYBBJOejY2sk/s1600/addlibraryproject.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="221" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYjVMeD3GPA-qwFRuTSVYBrzJuGO6TkiWCBV3w336zHYoHzIJpG9M75updscq0dijYK3fdYCsiDxm3vDcWmc967eR0jbyvcxpSPA-0i32740c2fFk5IZR9YjPRNfGp2wfzYBBJOejY2sk/s1600/addlibraryproject.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
At this time, all errors should have disappeared and you should be able to run Simple-Android-OCR-master project and test the app on a device with a camera.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimPilpTg0wfHlChAMe5nGpPSPE1btzxIlHQopnaPxBE8QXvAi6f35twx5OYPp4qRBHg1IIU1fhyPmlHvBVMbPRewoCmrFuozdgcb8mL6pmvCBY3XoEZ34x_H6t91bre2DzJDTS6yehz00/s1600/dev.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimPilpTg0wfHlChAMe5nGpPSPE1btzxIlHQopnaPxBE8QXvAi6f35twx5OYPp4qRBHg1IIU1fhyPmlHvBVMbPRewoCmrFuozdgcb8mL6pmvCBY3XoEZ34x_H6t91bre2DzJDTS6yehz00/s1600/dev.png" /></a></div>
<br />
I will write another tutorial very soon on how to improve the output.
Feel free to leave a comment.<br />
Refference<br />
<a href="http://kurup87.blogspot.com/2012/03/android-ocr-tutorial-image-to-text.html?showComment=1395155497966#c2799399846843518233" target="_blank">android-ocr-tutorial-image-to-text</a><br />
<br />Please be careful with NCBA Asset finance.http://www.blogger.com/profile/10733977270923746953noreply@blogger.com121