Announcement Announcement Module
Collapse
No announcement yet.
Spring Roo 1.2.4 @RooWebJson doesn't generate .aj files if backing jsonObject doesn't Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Roo 1.2.4 @RooWebJson doesn't generate .aj files if backing jsonObject doesn't

    I am using Spring Roo 1.2.4 with STS 3.2.0.

    I noticed something: @RooWebJson doesn't generate the controller .aj files if the backing jsonObject isn't annotated with @RooJpaActiveRecord.

    I have an Email object which is a domain class, so it has the following annotations:
    Code:
    @RooJavaBean
    @RooToString
    @RooJpaActiveRecord
    My EmailController has the following annotations:
    Code:
    @RequestMapping("/emails")
    @Controller
    @RooWebScaffold(path = "emails", formBackingObject = Email.class)
    @RooWebJson(jsonObject = Email.class)
    My EmailServiceController_Roo_Controller_Json.aj is generated perfectly.

    Now, I want an EmailBean object which represents a portion of the fields from my Email class, so that I can allow external systems to create an Email object by passing in only the relevant fields that are required via json, as the rest on the domain class are generated by the system when saving.

    I annotated EmailBean with:
    Code:
    @RooJson
    @RooJavaBean
    @RooToString
    As you can see, no @RooSpaActiveRecord, as this bean doesnt represent anything in the databse (not a domain class).

    Now, when creating an EmailServiceController and annotating with:
    Code:
    @RequestMapping("/service/emails")
    @Controller
    @RooWebJson(jsonObject = EmailBean.class)
    No EmailServiceController_Roo_Controller_Json.aj is generated. Why is this? If I add the @RooSpaActiveRecord annotation to my EmailBean, then the EmailServiceController_Roo_Controller_Json.aj is generated. Why does Roo only generate the json controller aj file if I annotate EmailBean with the @RooSpaActiveRecord annotation? Am I doing something wrong?
    Last edited by dleerob; Jul 2nd, 2013, 08:26 AM.

  • #2
    After looking a bit more into the actual json methods that are generated on a controller for a domain class annotated with @RooJpaActiveRecord, I noticed that they are all geared towards CRUD operations (ie affect the database). This means that from Roo's point of view, it wont make sense to generate controller json methods for entities that are not domain classes (stored in db), as it wouldn't know what business methods you are looking for. This means I would need to create my own manually in my controller, as only I know what it is I want to do. So I have gone ahead and created my own controller methods, and wont expect Roo to do the impossible

    Comment

    Working...
    X