Announcement Announcement Module
Collapse
No announcement yet.
Changing Roo code generate to your own pattern - possible? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Changing Roo code generate to your own pattern - possible?

    I have just looked inside the CLASSNAME_Roo_Controller code.If I aAm I reading this correctly the Roo Web Controller, when faced with a update, pulls all the records for related tables. It uses repository.findall() to put the whole table into the uiModel.

    That makes sense for a small table, but my apps will pick up too many records.

    So I want to change the behaviour to only pick up the rows in the many end of the relationship that have the existing relationship, then to add a button on the form for the user to add others.

    Options I can see -

    a) update code by hand
    b) change Roo code generation to my version
    c) write an Aspect that traps the ones I want to change and injects my code instead.

    Are b) and c) possible?

    What have you done when faced with this?

  • #2
    Could you describe your entities please?

    Comment


    • #3
      Do you mean the table layouts?

      In this example we have innovCatalogue table, and innoContents table. The catalogue is the parent, contents is the child.

      This is the offending Roo generated controller code for innovCalogue edit. I am reading this as pulling all the contents rows, which may be 1000s.

      Code:
          void InnovCataloguesController.populateEditForm(Model uiModel, InnovCatalogues innovCatalogues) {
              uiModel.addAttribute("innovCatalogues", innovCatalogues);
              uiModel.addAttribute("innovcataloguerelationshipses", innovCatalogueRelationshipsRepository.findAll());
              uiModel.addAttribute("innovcontentses", innovContentsRepository.findAll());
      In the jspx I am reading the innovContents to be in a dropdown, which wont work. I am thinking it should be a tag that shows the current content, and then offers a button to up up a selection form.

      This is one reason why I am thinking it best to move to Spring Web Flow. Webflow generated forms for entities would make a good plugin, or option for the web command.

      Here are the table definitions:

      [/code]
      <table name="innov_catalogues">
      <column name="catalogue_id" primaryKey="true" required="true" scale="0" size="10" type="4,INT"/>
      <column name="name" primaryKey="false" required="true" scale="0" size="255" type="12,VARCHAR"/>
      <column name="memo" primaryKey="false" required="true" scale="0" size="2000" type="12,VARCHAR"/>
      <column name="catalogue_content_id" primaryKey="false" required="false" scale="0" size="10" type="4,INT"/>
      <column name="catalogue_status_id" primaryKey="false" required="true" scale="0" size="10" type="4,INT"/>
      <column name="catalogue_type_id" primaryKey="false" required="true" scale="0" size="10" type="4,INT"/>
      <column name="catalogue_pre" primaryKey="false" required="true" scale="0" size="255" type="12,VARCHAR"/>
      <column name="catalogue_post" primaryKey="false" required="true" scale="0" size="255" type="12,VARCHAR"/>
      <column name="content_pre" primaryKey="false" required="true" scale="0" size="255" type="12,VARCHAR"/>
      <column name="content_post" primaryKey="false" required="true" scale="0" size="255" type="12,VARCHAR"/>
      <foreign-key foreignTable="innov_contents" name="innov_catalogues_ibfk_1" onDelete="none" onUpdate="none">
      <option key="exported" value="false"/>
      <reference foreign="content_id" local="catalogue_content_id"/>
      </foreign-key>
      <foreign-key foreignTable="innov_catalogue_relationships" name="innov_catalogue_relationships_ibfk_1" onDelete="none" onUpdate="none">
      <option key="exported" value="true"/>
      <reference foreign="from_catalogue_id" local="catalogue_id"/>
      </foreign-key>
      <foreign-key foreignTable="innov_catalogue_relationships" name="innov_catalogue_relationships_ibfk_2" onDelete="none" onUpdate="none">
      <option key="exported" value="true"/>
      <reference foreign="to_catalogue_id" local="catalogue_id"/>
      </foreign-key>
      <unique name="PRIMARY">
      <unique-column name="catalogue_id"/>
      </unique>
      <index name="cat_status">
      <index-column name="catalogue_status_id"/>
      </index>
      <index name="cat_type">
      <index-column name="catalogue_type_id"/>
      </index>
      <index name="content_id_index">
      <index-column name="catalogue_content_id"/>
      </index>
      </table>

      <table name="innov_contents">
      <column name="content_id" primaryKey="true" required="true" scale="0" size="10" type="4,INT"/>
      <column name="name" primaryKey="false" required="true" scale="0" size="80" type="12,VARCHAR"/>
      <column name="selected" primaryKey="false" required="true" scale="0" size="10" type="4,INT"/>
      <column name="content" primaryKey="false" required="true" scale="0" size="3000" type="12,VARCHAR"/>
      <column name="content_type_id" primaryKey="false" required="true" scale="0" size="10" type="4,INT"/>
      <column name="memo" primaryKey="false" required="true" scale="0" size="2000" type="12,VARCHAR"/>
      <foreign-key foreignTable="innov_catalogues" name="innov_catalogues_ibfk_1" onDelete="none" onUpdate="none">
      <option key="exported" value="true"/>
      <reference foreign="catalogue_content_id" local="content_id"/>
      </foreign-key>
      <unique name="PRIMARY">
      <unique-column name="content_id"/>
      </unique>
      </table>
      [/code]

      Comment


      • #4
        Originally posted by greg.soulsby View Post
        Do you mean the table layouts?
        I was more interested in the Entities themselves —but nevermind that. I assume you're using Repositories with Spring Data JPA. Spring Data support paging, which perhaps solves part of your problem here. Petri Kainulainen wrote an excellent article "Spring Data JPA Tutorial Part Seven: Pagination" about this subject.

        Unfortunately I cannot assist in the Roo-generated interface part of your question as I've abandoned jspx in the development stage. I use Freemaker combined with Tiles instead as that gives me the full control I need.

        The options if you're not satisfied with the Roo generated code like a finder you choose your a) alternative, i e that you push in the code and re-implement it yourself. I cannot say if options b) and c) are viable or worth exploring for you, but personally I would choose your a) option and not bother with the other two.
        Last edited by MiB; Jan 29th, 2013, 01:02 PM.

        Comment

        Working...
        X