Spacer for JHeadstart Generation

0

During the JHeadstart workshop I am teaching this week there as a question: How can I – in a two-column layout – force two adjacent fields to be positioned under and above each other, rather than next to each other. In other words:

normally the generator would produce:

Field 1                Field 2
Field 3                Field 4
Field 5                Field 6

However, in this case I would like the page to look like this:

Field 1
Field 2
Field 3                Field 4
Field 5                Field 6


I think the following would work: create two spacer attributes in the ViewObject – transient attributes called spacer and spacer2 of type BlobDomain, one between field1 and field2 and the other one between field2 and field3. Generate the ViewObjectRowImpl and implement the getSpacer and getSpacer2() methods: return null;. In the jHeadstart property editor, set the prompt to a space (” “), the displayType to image Now when you generate the page, the JAG creates:

Field 1                spacer
Field 2                spacer 2
Field 3                Field 4
Field 5                Field 6

And since the spacer attributes – no image – are virtually invisible, I think this will reduce in the output to:

Field 1
Field 2
Field 3                Field 4
Field 5                Field 6

Of course, we abuse the Model here to get the generation result we want. That is not very MVC and not very architecturally wonderful. But hey, it works! (I think) – as a generation help. You may want to remove the spacer attribute from the VO once generation of the JSPs is complete.

Note: the original post spoke about displayText fields; however, in that case you still get an disabled Input of type text which – depending on the CSS setting that may result in a box-frame drawn on the page. The solution with an empty image arose from a discussion with Steven and Martin during the JHeadstart Workshop this week. The original question that prompted this post was posed by Martijn.

Share.

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director for Fusion Middleware. Consultant, trainer and instructor on diverse areas including Oracle Database (SQL & PLSQL), Service Oriented Architecture, BPM, ADF, Java in various shapes and forms and many other things. Author of the Oracle Press book: Oracle SOA Suite 11g Handbook. Frequent presenter on conferences such as JavaOne, Oracle OpenWorld, ODTUG Kaleidoscope, Devoxx and OBUG. Presenter for Oracle University Celebrity specials.

Comments are closed.