This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!

shukla raghav

Ranch Hand
+ Follow
since Aug 03, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by shukla raghav

Hi Kathy, Bert and Elisabeth,

I am eager to put Lambdas and Streams API to practice. I am sure this book would surely demistify some of these complex topics which are a Paradigm shift for a Java 8 aspirant.
I am personally excited to learn implementation of functional programming techniques and to understand and appreciate its benefits over previous ways of handling things in Java.

My excitement is soaring high

Thanks for this much awaited book

Sometimes I think that knowing Java is more of an impediment to learning JavaScript than a help. Be sure not to try and take OO in JavaScript beyond what is natural to the language. Be sure to embrace the functional nature of JavaScript and not rely over-heavily on the OO aspect.



Yes Mr. Bibeault, exactly that was my feeling while i started exploring object oriented javascript. There are certain features in OO based JS that at once seem like a great feature but you exactly don't know how are these utilized in a practical application. At one point i thought why not to go ahead with purely functional way of JS but then being a java developer the ease and manageability aspect of OO paradigm pushes you to go for the Object Oriented version of a technology.

Since Mr Raynders has well elucidated the strange capabilities of javascript, i have used the later approach he has suggested and works well for me. Thank you Mr Raynders.
I have recently started following Javascript and that too Object Oriented JS and also i am impressed with Object Oriented JS except for its poor support for collections. Anyways getting back to the main topic..As an exercise i tried to create a Validation library for my application but it seems the instance values scopes are either not understood by me or else this is strange behavior. In order to illustrate this behavior i have sliced down the library to basic minimum in order to present here.

  • The below given sample validates if the email format is correct or not.
  • The problem is visible when you enter the correct format like
    johndoe@gmail.com and click submit.
  • It will trigger the registered event which modifies the IS_ERROR
    instance field to false and displayed by alert 1.
  • Then if you click the submit button the update function is triggered by onclick event of the submit button that tries to display the
    IS_ERROR value again as per the alert 2.


  • surprizingly these two values are different. How is that possible?
    What am i missing?

    test.html


    validations.js

    Scenario : This is a customer support application and the scenario in question is Issue Resolution Scenario. Support Manager clicks a certain link which shows list of issues to be resolved. Corresponding to each issue is an input field where the Support Manager can add the name of a Support Executive and submits the form. This UI form is rendered from issueResolution.jsp .



    Backing Form Object : Resolution.java



    issueResolution.jsp



    If you see the issueResolution.jsp, the form would have multiple input tags. I expect the value of name attribute to form the Key in the allotments map in the backing object and the data entered by the user to be binded to corresponding value in the allotments map in the backing object (i.e. Resolution object).

    Since this is not a straight forward conversion. Using Property Editors and WebDataBinders is one way i would like to explore. But in this scenario it seems a little complicated. I am open to all ways except MessageConverters as of now.




    4 years ago
    Well i used apache commons codec for encoding and decoding the xml. escaping will not work here. Yes the encoding did the trick.

    5 years ago
    Hi Surendra, Actually i am not using any JSP as of now. Currently we are testing our REST API using FireFox Rest Client. yes it has got something to do with the way parameter values are passed although it seems to me that the = sign in prolog <?xml version="1.0" is taken as another assignment operator. But quite possible that replacing spaces with %20C or whatever HTML entity for space may do the trick.
    5 years ago

    In my current application i am required to pass two parameters to the REStful Spring MVC application. One parameter is an id and the other is an xml passed as a string.



    There is a complex operation that needs to be performed before the spring container passes the parameter to the controller method. Therefore i am using a Custom HttpMessageConverter to parse the obtained XML into a Template object.

    Here is the part of the Custom Converter that i am using



    To Test this i am using FireFox Rest Client (see attatchment)

    The problem is that i am just recieving <?xml version from http request where as the typeid parameter is perfectly mapped.

    All suggestions are welcome.
    5 years ago
    So Jayesh you mean to say that if the value in rest of the fields remain unchanged then there wont be any update operation for rest of the fields, Which to me does make some sense. In such a case we may for general purposes consider no additional cost associated with complete update. Do you have reference to any authentic resource that confirms the same. In that case it will save me lot of effort.

    5 years ago
    Well, I have considered writing utility that dynamically generate SQL at runtime with variable number of placeholders. The number of placeholders would always be same as the number of non-null params. This way i can use APPROACH-2 abstracting the logic for dynamic query generation and null-checks. I will post the code as soon as it is done.

    What i am surprised is that this is a pretty common use-case. How come i am unable to get some kind of a standard best practice for this ? how do you all handle such a situation. An update is mostly on partial data.

    Wish to look for as many replies as possible



    5 years ago


    I am myself surprised that this question never occurred to me before but this time i am bothered since i am creating my own application.

    I have a TaskDetail class that has 30 fields. while updating there could be only a small part of TaskDetail that may be updated like just the "endDate" of the task. We can use two strategies to update this field.

    APPROACH 1 : Update entire object with all the 30 fields and let the rest fields be overwritten in the database with the same value expect the changed field which will be updated with new value.
    OR
    APPROACH 2 : Update just the field that has been changed. In this case we would treat Employee as a DTO and just populate the "endDate" field with new value since it is the only field that needs to be changed.


    Both the approaches seem to have its pros and cons

    APPROACH 1 : (PROS) - Its a cleaner approach. (CONS) - We are unnecessarily over-writing 29 additional field for the sake of one field.

    APPROACH 2 : (PROS) - We are just updating the fields that are modified (CONS) - Makes the DAO dirty looking because we would need 30 null checks to identify which of field have to be updated.

    This problem is making me a little uncomfortable.

    Which of this approach is an accepted one or there is a third approach? I am not very much in favor of using hibernate although prefer Spring JDBC template.
    5 years ago
    I have developed a multi-module maven project with 9 modules. i wanted to test one of my service classes. so i simply wrote a main method in the class and executed the class and was left surprized with an exception stack that said "FileNotFoundException" and futher the reason was - The filename, directory name, or volume label syntax is incorrect

    Here are the details



    I am simply passing an XML as a string to build() method which processes the XML to create a Template Object using SAX parser. I dont think so the code here is causing any problem but it has got something to do with maven. I am recieving following exception when i run this main method.

    Exception in thread "main" java.io.FileNotFoundException: D:\Raghave\OSRMediaManager\mediamanager\documentmanagementsystem\ <page> <attribute key="color" param="@{BaseColor.BLUE}"\> <attribute key="size" param="12.2f"\> <\font> <content class="java.lang.String"\> <attribute key="anchor" param="123i" \> <attribute key="background" param="123i,145f,134d" \> <attribute key="font" param="${chunkfont}"\> <position xpos="23" ypos="25"\> <\title> <\template> (The filename, directory name, or volume label syntax is incorrect)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at javax.xml.parsers.SAXParser.parse(Unknown Source)
    at com.bluebench.mediamanager.dms.utility.TemplateBuilder.build(TemplateBuilder.java:41)
    at com.bluebench.mediamanager.dms.utility.TemplateBuilder.main(TemplateBuilder.java:70)




    If you look at the stack you will see "java.io.FileNotFoundException: D:\Raghave\OSRMediaManager\mediamanager\documentmanagementsystem\" here this path is the path of the current maven module from which this class TemplateBuilder and main method are executed. How is it possible that JVM is unable to find the path of module from which the main method is executed ?

    Is It something like we cannot directly execute a main class from within maven module. IF this is true, i wanted to know why so and what are the options available for a quick test in that case ?

    I AM STUCK..
    5 years ago
    Since i am about to go on a work from home leave and i am required to create a PoC. For the same reason i am required to connect to my Oracle XE installation from home.

    here are the list of things that i have already done.

    a. Installed oracle XE 11.2 on my office machine (windows-7).
    b. since the IP addresses are generally dynamic i have installed a no-ip dynamic DNS manager. It provides me a Host name as abc.no-ip.biz which i can replace in my jdbc url string as hostname.
    c. I enabled ports 1521 and 8080 in my office machine as follows - control panel > windows firewall > inbound rule > new rule > provide a name and provide the ports which you wish to allow incoming connection, similarly for the out bound rule
    d. i installed Oracle SQL Developer for 11.2 at my home machine (windows-7)

    i tested the server using SQLPLUS client installed locally on the office machine connect username\password and it connected perfectly. when i connect from home it does not connect.

    connection anme : bbenchdb
    username : system
    password : mypass

    host : bbench.no-ip.biz
    sid : xe

    to further investigate

    when i ping the host address i.e. bbench.no-ip.biz from my home i get proper reply, but when i issue command : telnet bbench.no-ip.biz 1521 then i get a reply could not open connection to host on port 1521.

    One more thing is that the Dynamic DNS service provides a different IP than the one that i see when i do ipconfig.

    It seems the IP address that is mapped by Dynamic DNS service is not of my office machine but the router which it also specifies in its GUI as (Router/NAT).

    How do i connect to my office Oracle XE server.


    5 years ago
    Hi All,

    I am using Spring MVC to a build a RESTFul application with JSON. Form my application the JSON needs to be parsed into an object before being used by the controller. For example.



    I know this can work fine using @RequestBody if field values map to the attributes in the Employee object

    But how about if the Employee Form is composed of PersonalDetails, EducationalDetails, WorkExperience and i need to apply some complex parsing to pass three different Objects to the handler instead of one.


    Since the data is passed in the form of JSON, i need to parse the JSON into the above mentioned three object and then pass to the handler.

    There are two different approaches i have found.

    1. Using @InitBinder with PropertyEditorSupport
    2. Using the Converter - org.springframework.core.convert.converter.Converter

    The @InitBinder approach provides a setAsText(String) method. Is the setAsText method going to recieve the entire JSON as an argument and i would have to write custom logic for parsing and binding the result to PersonalDetail, EducationDetail and WorkExperience objects and set in the binding result.
    Similarly for Converter we have to implement convert(String source) method.

    My question is what if there are 5 Post methods in a controller each requiring such binding. Do i need 5 converter classes, one for each type of conversion? i may have 20 controllers in my application , that would mean 100 additional converter files for the application. That doesn't sound encouraging.

    Any strategies ?




    5 years ago

    Is it true that the naming convention for RESTFul controller methods should not be verb based like i wanted my controller methods to be named as

    showDocumentType, editDocumentType and listDocumentType, searchDocumentType, addDocumentType

    is it true all RESTFul controller method names should be based on HTTP methods as in

    getDocumentType, setDocumentType, putDocumentType

    How would a new developer make out for what functions are performed by this controller. I wanted my Controller methods to map to functional specification Use-Cases

    Please let me know what are best practices and what should be done in my case?
    5 years ago