Announcement Announcement Module
No announcement yet.
Using another frontend in ROO apps. Expecting reply from some senior member. Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    i have tried out the example.while the create owner functionality is working,i couldn't get any other parts of the sample application to work and also list of owners is not been displayed.

    please help me out to understand exact how extjs is implemented on spring roo.
    Can you provide more details on what's not working in the example? I tested it before I put it up there, and all the functionality worked pretty much the same as the petclinic example that comes with roo. Can you give me some specifics of what actions you were performing and what did/or didn't happen. Are you getting any errors in the web server log?

    Basically, I have it setup so ExtJS is used to create a javascript application that sends requests to the Roo application to perform CRUD actions on the data.


    • #17

      hi btlife,i was able to add the owner,list of owners is not displayed. And i am not able to create a pet for particular owner and not able to work on other functionality ,it comes loading.
      please help me about this.

      thanks in advance


      • #18
        I pushed out a couple of changes:
        1. Updated FlexJson to version 2.1 in the pom.xml
        2. Removed the Pet and Vet object from the Json Serialization in
        3. Added a check if the record is dirty in the rowclick listener of the OwnerPetsEditor.js

        One thing to keep in mind, is that this is just an example, and there is not a lot of validation, so if the record fails to save because information is missing or incorrect, it won't really tell you that it didn't save. If you are using Firebug you can see the response in the firebug window, to see what is being passed and what the server responded with.

        Also, if you get in trouble you can always refresh the page and start over, or restart the tomcat server and start over. The database is cleared on each restart of tomcat. Refreshing the page doesn't remove any data, but causes everything to reload from scratch.

        You can also, go back and forth to the original UI, if you want to make changes there and see them appear on the ExtJS side.

        Clicking the Roo Banner, will switch back and forth between the Roo generated UI and the ExtJS UI.

        One point to keep in mind the Owner and Vet objects are defined in clinic.roo as requiring at least 3 characters in the first name, last name, and 6 characters in the email. If these aren't met there isn't a validation message to tell you.

        Also, the visitDate and employedSinceDate in the clinic.roo have the Past setting so they required dates in the past.

        When testing I typed 3 chars in each string field, 6 in the email and set all dates to anything before today.

        Let me know if this worked for you.


        • #19

          thanks btlife,now its working fine.thanks for your help.


          • #20
            Originally posted by chandramohan View Post
            thanks btlife,now its working fine.thanks for your help.
            Sure thing, hope the example helps out


            • #21

              Thank you for sharing that application with us. It is usefull.
              Good Work.

              Thanks and regards
              Privin Thomas


              • #22
                Originally posted by Privin View Post

                Thank you for sharing that application with us. It is usefull.
                Good Work.

                Thanks and regards
                Privin Thomas
                Sure thing

                I just hope it helps someone shorten the research time it took me to figure it all out.

                If we all help each other, we all win


                • #23
                  My curl insert test won't map properly.

                  Hi btlife,

                  I am repeating a post that I made to the manning "spring roo in action" book. I am hoping that you might be able to give me some clues to why my curl call is not working.

                  I will try to keep this as short as possible. Please ask me for what you need to see and I will be happy to post it. I apologize for the amount of text.

                  I am using the suggestions made by btlife at to wrap the json controller methods to return the json that sencha's ExtJS is expecting. I did this with the push-in for the StudentController. I have included it below.

                  Can someone tell me what is going wrong here? BTW, the GET works fine.

                  It seems to have trouble mapping on the input in the Student student = Student.fromJsonToStudent(json); call. In other words, it is failing before it gets the JSONSerialization.

                  I ran
                  curl -v -X POST -H "Accept: application/json" http://localhost:8080/MySchool/students -d '{address1:"8116 Bogus Drive",address2:"NONE",city:"Gaithersburg",country :"US",firstName:"Denis",lastName:"Putnam",lastUpda ted:"07/07/13",middleName:"M",personID:"1111",phone1:"999-999-999",phone2:"NONE",postalCode:"99999",province:"MD ",version:0,whoUpdated:"denis"}'

                  to create a new student record, and it fails in the ObjectBinder class in this method:

                  public Object bindPrimitive(Object value, Class clazz) {
                  if( value.getClass() == clazz ) {
                  return value;
                  } else if( value instanceof Number && clazz.equals(Double.class) ) {
                  return ((Number)value).doubleValue();
                  } else if( value instanceof Number && clazz.equals(Integer.class) ) {
                  return ((Number)value).intValue();
                  } else if( value instanceof Number && clazz.equals(Long.class) ) {
                  return ((Number)value).longValue();
                  } else if( value instanceof Number && clazz.equals(Short.class) ) {
                  return ((Number)value).shortValue();
                  } else if( value instanceof Number && clazz.equals(Byte.class) ) {
                  return ((Number)value).byteValue();
                  } else if( value instanceof Number && clazz.equals(Float.class) ) {
                  return ((Number)value).floatValue();
                  } else if( value instanceof Boolean && clazz.equals(Boolean.class) ) {
                  return value;
                  } else if( value instanceof Long && clazz == Date.class ) {
                  return new Date( (Long)value );
                  } else {
                  throw new JSONException(String.format("%s: Don't know how to bind %s into class %s. You might need to use an ObjectFactory instead of a plain class.", getCurrentPath().toString(), value, clazz.getName()) );

                  This is what I get back:

                  * About to connect() to localhost port 8080 (#0)
                  * Trying ::1...
                  * connected
                  * Connected to localhost (::1) port 8080 (#0)
                  > POST /MySchool/students HTTP/1.1
                  > User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5
                  > Host: localhost:8080
                  > Accept: application/json
                  > Content-Length: 272
                  > Content-Type: application/x-www-form-urlencoded
                  * upload completely sent off: 272 out of 272 bytes
                  < HTTP/1.1 400 Bad Request
                  < Server: Apache-Coyote/1.1
                  < Content-Type: application/json;charset=UTF-8
                  < Content-Length: 584
                  < Date: Sun, 07 Jul 2013 17:05:24 GMT
                  < Connection: close
                  * Closing connection #0
                  {"data":null,"message":"[ ]: Don't know how to bind %7Baddress1%3A%228116+Bogus+Drive%22%2Caddress2%3A %22NONE%22%2Ccity%3A%22Gaithersburg%22%2Ccountry%3 A%22US%22%2CfirstName%3A%22Denis%22%2ClastName%3A% 22Putnam%22%2ClastUpdated%3A%2207%2F07%2F13%22%2Cm iddleName%3A%22M%22%2CpersonID%3A%221111%22%2Cphon e1%3A%22999-999-999%22%2Cphone2%3A%22NONE%22%2CpostalCode%3A%22999 99%22%2Cprovince%3A%22MD%22%2Cversion%3A0%2CwhoUpd ated%3A%22denis%22%7D into class You might need to use an ObjectFactory instead of a plain class.","success":false,"total":0}Deniss-MacBook-Pro:workspace-sts-3.2.0.M1 denisputnam$
                  import flexjson.JSONSerializer;
                  import flexjson.transformer.DateTransformer;
                  import java.util.ArrayList;
                  import java.util.Collection;
                  import java.util.Date;
                  import java.util.List;
                  import org.springframework.http.HttpStatus;
                  import org.springframework.http.ResponseEntity;
                  import org.springframework.roo.addon.web.mvc.controller.json.RooWebJson;
                  import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold;
                  import org.springframework.stereotype.Controller;
                  import org.springframework.web.bind.annotation.PathVariable;
                  import org.springframework.web.bind.annotation.RequestBody;
                  import org.springframework.web.bind.annotation.RequestMapping;
                  import org.springframework.web.bind.annotation.RequestMethod;
                  import org.springframework.web.bind.annotation.ResponseBody;
                  @RooWebScaffold(path = "students", formBackingObject = Student.class)
                  @RooWebJson(jsonObject = Student.class)
                  public class StudentController {
                  	@RequestMapping(method = RequestMethod.POST, headers = "Accept=application/json")
                      public ResponseEntity<String> createFromJson(@RequestBody String json) {
                          //Student student = Student.fromJsonToStudent(json);
                          //HttpHeaders headers = new HttpHeaders();
                         // headers.add("Content-Type", "application/json");
                          //return new ResponseEntity<String>(headers, HttpStatus.CREATED);
                  		HttpStatus returnStatus = HttpStatus.BAD_REQUEST;
                  		JsonObjectResponse response = new JsonObjectResponse();
                  		try {
                  	        Student student = Student.fromJsonToStudent(json);
                              returnStatus = HttpStatus.CREATED;
                  			response.setMessage("Student created." );
                  		} catch(Exception e) {
                  		// Return the created record with the new system generated id
                          return new ResponseEntity<String>(new JSONSerializer().exclude("*.class").transform(new DateTransformer("MM/dd/yy"), Date.class).serialize(response), returnStatus);
                  Last edited by denismp; Jul 7th, 2013, 02:40 PM.


                  • #24
                    Thank you Hany Marcos for this solution:

                    String myJson = URLDecoder.decode(json);
                    System.out.println( "myjson=" + myJson );
                    Student student = Student.fromJsonToStudent(myJson);

                    The hex codes were the problem. The URLDecoder.decode() fixes it!

                    The string coming in from curl looked like:

                    %7Baddress1%3A%229999+Bogus+Drive%22%2Caddress2%3A %22NONE%22%2Ccity%3A%22Gaithersburg%22%2Ccountry%3 A%22US%22%2CfirstName%3A%22Denis%22%2ClastName%3A% 22Putnam%22%2ClastUpdated%3A%2207%2F07%2F13%22%2Cm iddleName%3A%22M%22%2CpersonID%3A%221111%22%2Cphon e1%3A%22999-999-9999%22%2Cphone2%3A%22NONE%22%2CpostalCode%3A%2299 999%22%2Cprovince%3A%22MD%22%2Cversion%3A0%2CwhoUp dated%3A%22denis%22%7D

                    The URLDecoder.decode() converted the hex characters to ascii.