DTO, DAO - Displaying/Formatting Data in the Presentation Layer

I need display multiple fields from a DTO throughout the presentation layer. What is the best way to format display data without duplicating the logic throughout presentation layer?
Example
I have a Person DTO that has first name, last name, and suffix 'getters' and am constantly showing the data out as "first last, suffix"
Options
1 - Create a utility class that formats the name of the Person DTO.
public class DisplayUtil{
     public static String DisplayName(PersonDTO person){
          return person.getFirstName() + " " + person.getLastName() + ", " + person.getSuffix();
}2 - Add a getter into the DTO that gets the data
public class PersonDto{
     //Other fields, getters, and setters
     public String getName(){
          return person.getFirstName() + " " + person.getLastName() + ", " + person.getSuffix();
}3 - Create a domain object (aka business object) using the "entity inherits from transfer object strategy".
public class Person extends PersonDto{
     public String getName(){
          return person.getFirstName() + " " + person.getLastName() + ", " + person.getSuffix();
}The easiest to implement now would be Option 2 above but it distorts what the DTO is supposed to be used for (which is transferring data).
What have you done in the past? What is an "acceptable" best practice? Are there other options that I haven't listed above that you use?

So, from what you advise you would have the following
code in <b>all</b> of the JSP pages of the Struts
app?
<c:out value="${person.firstName} ${person.lastName}"
/>
<c:logic test="${not empty person.suffix}">
     <c:out value=", ${person.suffix}" />
</c:logic>The problem that I see with this is that changes
would be incredibly difficult at a later date, since
every page contains the logic about displaying the
proper name format. (Say the client wanted to change
to always display the last name first instead of the
first name for all the pages. With this logic code
being on every "template", their could be hundreds of
pages to change. This is where I could see the
benefit of a utility class like Option 1.)This is what the include directive is for. The JSP tags in your example should not exist (physically ) in each JSP file. They should be stored in a single JSP fragment file.
The JSP fragment file is then "included" in each page via include directive. If you need to change anything for this at a later date, then you go to the single fragment file and make the change once.
<html>
<head><title>Including Shared Stuff in JSP Pages</title></head>
<body>
<%@include file="shared/text.jspf" %><br/>
<font size="10">What It Do</font><br/>
<jsp:include page="shared/text.jspf" />
</body>
</html>When each JSP file is converted to a Java servlet by the JSP Engine, it will grab the shared fragment and include it in the code for the servlet.

Similar Messages

  • How to process data in the past based from data in the present

    hello guys,
    i have a problem in my labview programs. how to process data in the past based from data in the present ?
    i have a formula self-organizing maps
    this formula is looking for D1, D1 is neuron index that will be searched for the smallest value.and the result are D1=2 ,D2=5, D3=17 from calculating with formula  .it means the smallest value is 2, "2" from weight [2 2] in file attached.
    and then it will be in other formula
    it mean [2 2] + 0.5 ( [1 1]-[2 2] ) = [1.5 1.5]
    and the weight will be  [1.5 2 2 ] in matrix
                                              1.5 3 5
    I would appreciate any input/help on solving this
    thanks
    Attachments:
    dika.vi ‏16 KB
    weight.txt ‏1 KB
    data .txt ‏1 KB

    Hi Ronny Hanks,
    Moving your records from internal table into the database table depends upon various scenarios :-
    1. If you use INSERT statement.
    INSERT <database_table> FROM TABLE <internal_table>.
    But in this case, you need to make sure that you don't have any duplicate entries in your internal table that violates data entry into database table, else you will get a dump.
    INSERT <database_table> FROM TABLE <internal_table> ACCEPTING DUPLICATE KEYS.
    In this case, you are forcefully inserting duplicate records into your database table which may lead to data redundancy in your database table.
    2. If you use UPDATE statement.
    UPDATE <database_table> FROM TABLE <internal_table>.
    This will update the existing records in your database table from the internal table.
    3. If you use MODIFY statement.
    MODIFY <database_table> FROM TABLE <internal_table>.
    This statement works both in combination of INSERT & UPDATE statements.
    Existing records (in database table) will be eventually updated/modified and new records (not in database table currently) will be successfully inserted into the database table.
    Hope this solves your problem.
    Thanks & Regards.
    Tarun Gambhir.

  • To display Last Date of the Month in Financial Reporting studio 9

    Hi
    I want to display last date of the month in header in Financial Reporting studio 9 . Is there any function which displays the last date of the month as per user selection .
    for example
    If user select month of Jan it should display Jan 31st, 2009
    If user select month of Feb it should display Feb 28th 2009
    Thanks

    Unless you name your Months like that you cannot do it. A large team from a major consulting firm told me for a year that it was not possible and convinced management that financial statements don't need dates.
    Management decided that we do need dates (because all financials need dates, look at any text book). I figured out a pretty sweet solution that is simple and easy to use and maintain. The users love it. Management loves it.
    I'm not giving it away though.

  • How to download data to the presentation server in background?

    Hi,
    I would like to download data to the presentation server in background.
    Currently, the report uses FM GUI_DOWNLOAD to download in foreground.
    However, this FM does not work in the background.
    But please let me know how to download to the presentation server in background.
    Thanks and regards,
    Anishur

    Moderator message - FAQ - Please search before asking - post locked
    Rob

  • Accessing the presentation layer

    Does anybody know how to access the presentation layer using a tool other than the OBIEE front end? What if I wanted to query the presentation layer from Excel or SQL Developer. Does anyone know how to do that?

    You need to use the ODBC connection. OBI Presentation Dashboard use it and Excel also.
    Here an example how to access the presentation catalog from Excel :
    http://gerardnico.com/wiki/dat/obiee/import_data_from_obiee_to_excel
    And here how to set up the ODBC :
    http://gerardnico.com/wiki/dat/obiee/obiee_client_tools#setting_up_odbc

  • Reordering the presentation layer in BI Server repository

    Is there a way to re-order the presentation layer in the BI server repository? Currently if I add something new to a table in a subject area - it is always placed at the bottom. Also, if I add a whole new table - it is also placed at the bottom. I then have to remove everything below where I want it - and add it back. It seems like there must be an easier way! Any help is most appreciated.

    I figured there is something, and I know it sounds dumb, but i've looked everywhere - and no up or down buttons. On right click I have rename... I am in the Administrator tool for the repository.

  • Why is Time Machine displaying files only in the present not the past?

    Hi,
    My PowerBook G4 recently had its Logic Board replaced. Since Time Machine identifies the machine to backup thanks to its MAC Ethernet address and, since after a Logic Board switch my MAC Ethernet address had changed, I had to reconfigure TM so that the external hard drive reassociates with the new MAC Ethernet address and continues to backup in the same backup folder. For that I used this hint posted on MacOSXhints.com :
    http://www.macosxhints.com/article.php?story=20080128003716101&query=time%2Bmach ine%2Blogic
    While performing this hint enabled me to have my new backups in the original backup folder, and access all my backups through finder, I cannot view any backups in Time Machine star-field mode. Whenever I click on "Enter Time Machine" I correctly warp into the star-field, but I only see the present. I cannot go back in time and the time line on the side doesn't show any dates in the past. The finder window at the front displays only what is currently on my PowerBook HDD, and the finder windows that precede it are all dark grey, empty and un-clickable. What is peculiar is that when I click on Time Machine Preferences, the Panel can show the date of the oldest backup.
    To sum up: Time machine has no problem backing up my files in the original backup folder of my external HDD (I can see all my new backups in the same backup database folder as the ones before the Logic board switch), I can access all my backed up files via Finder, but when I enter Time Machine star-field mode, it doesn't show me any of my backups. I really like the ease of use of the star-field mode, and I find it frustrating to have to look at my backups in plain old Finder.
    What I don't know is whether hint I described above might have introduced errors that provoked the error or whether this might be due to the fact that while my computer was going for repair, I connected the external HDD containing my backup with two computers running Mac OS X 10.4 to retrieve some backed up files.
    My case must probably be quite rare, but since I haven't found any solutions to this date, I'm posting it now.
    I would be extremely grateful if anyone had a solution for this, or an intuition on the different parameters to modify to correct this Time Machine problem. Any contribution will be helpful. Thank you very much.

    gbullman,
    You say that the logic board was replaced? Then you will not be able to continue backups to the SAME backup set.
    *_Time Machine Always Performs a Full Backup After a Full Restore_*
    Actually, this is normal. Anytime your hardware has changed, or you have reinstalled the operating system again, Time Machine will perform a new full backup.
    *Full Backup After Restore*
    Bear in mind that in all cases Time Machine will perform a full backup after a full restore. This is normal. Time Machine will resume incremental backups after the full backup has completed. To view previous backups, Control-click or right-click the Time Machine icon in your Dock or Option-click the Time Machine menu extra and Choose "Browse Other Time Machine Disks," then select your previous backup volume. You will enter Time Machine and be able to browse your previous back ups and restore files. [http://support.apple.com/kb/TS1338]
    So even on unchanged hardware, if you reinstall your system software and restore your user data, Time Machine starts anew, and you will not be able to resume backing up with the same history as the previous backups.
    While there may be ways to fool/hack Time Machine into recognizing previous backups without performing another full backup, they are likely rather elaborate. Ultimately, though, in a couple of months, all the effort to preserve old backups may seem pointless. After all, Time Machine will eventually purge away that data anyways as it replaces it with new files.
    It may simply be easier to begin a fresh series of backups while saving the previous backups until your satisfied that you have enough history built up. Then delete the old backups.
    *Why Can’t I Resume Backups?*
    You see, Time Machine was designed to restore your Macs’ immediate environment in case of system crashes or accidental deletion of user files. As a result, reinstalling your Mac OS system software or changing your hardware requires a fresh set of backups since older backups would not accurately represent the current state of your Mac.
    Additionally, if a user has had to reinstall the system software, then resuming backups to the same set could later reintroduce the very issues that forced the reinstall in the first place. Furthermore, maintaining backups that were started with an older Mac, introduces the possibility of restoring system files that were never intended for the new Mac.
    If you require long-term archival storage of files, then you need another backup strategy.
    Hope this clarifies some things.
    Cheers!

  • LX25 displays wrong data for the entered date range

    System says "Inventory not executed" status for the bins even if Inventory is executed for the bins in the date range provided in the selection screen.
    For e.g.
    I execute report for Warehouse XYZ. I specify date range as 01.04.2014 to 31.03.2015.
    I get some bins in the status "No Inventory executed".I presume that Inventory is not executed for these bins within this period.
    But when I go to each bin in the status "No Inventory executed" I find that The bins are counted on the dates 24.09.2014 and then on 05.04.2015.
    Then I changed the date in the selection screen to 01.04.2014 to 05.04.2015.
    Those bins which were earlier in the status of "No inventory status executed" are now not present in this status.
    Does this mean that LX25 report is based on the Last counted date? Or the report is not displayed correctly for the date range provided?
    I want to know the criteria based on which the LX25 report works.
    Thanks In Advance.

    Hi Jurgen,
    Below information I found from the LX25 report info in SAP.
    Inventory status
    Description
    This report provides information on the stock in the storagae bins and presents this on the screen.  You can limit your selection by warehouse number, storage type and storage bin, or choose the following criteria:
    Total number of bins
    Number of inventoried bins in the selection period
    Bins with active inventory
    Bins with planned inventory
    Bins without executed inventory
    From this list, you can obtain a plan of the individual storage bins with further detail information within a storage type, by clicking on the relevant line total.
    It clearly shows that the report should be able to show the number of inventoried bins in the selection period, which it doesn't. Does it mean that system is not working as expected?
    Regards
    Soumya

  • Displaying HTML data in the xml report

    hi
    can anybody help me out on how to display the HTML data in XML report, for example the data in the table is in the following format with HTML tags attached to it
    *&lt;b&gt;Test Good display as normal text&lt;b&gt;*
    +&lt;i&gt;Test Italicized &lt;i&gt;+
    i would like to display the above data in the XML report as a following with "Test Good display as normal text" as BOLD and "Test Italicized" as Italicized
    Test Good display as normal text Test Italicized
    if anybody came across similar issue please help me out.
    Regards
    Hemi.

    Hi..
    Check out this link..hope this helps..
    http://blogs.oracle.com/xmlpublisher/2007/01/formatting_html_with_templates.html

  • Columns are not displaying in a Dimension in the presentation layer

    Hi All,
    I have a Dimension in one of the subject area which has 3 columns. It was working fine but yesterday, we have an issue about this. These columns are not displaying anymore in the dimension.
    I have checked in the Repository and from the Presentation services for the permissions and they look fine. Is there anything else am missing. If so, where I need to check.
    Kindly help me on this.
    Thanks,
    Imtiaz.

    Hi,
    Check three things.
    1. Try to login Admin user and check whether those columns are present or not.
    2. Try to login different browser.
    3. Cross check privileges for login user (what role has assigned ).
    Note: Clear the browser cache and all Bi server cache and check.
    Hope this help's
    Thanks,
    Satya Ranki redddy

  • How to display a date in the future?

    Hello,
    I play sport every Thursday. On my website I want to be able to display the date of the next Thursday that we are meeting. I want to be able to do this on an a continual basis. i.e. When someone looks at my site on Friday, it will display the actual date that the next Thursday falls on, and so on.
    Can anyone help with how to code this?
    Cheers
    Mitch

    use cal = Calendar.getInstance() to get the current date/time
    use cal.get(Calendar.DAY_OF_WEEK) to get what today is
    calculate n = days to next Thursday
    advance the calendar with cal.add(Calendar.DATE, n).

  • How to use format-date with the report parameter

    Hi all,
    How to use the format-date function with this tag,
    <?param@begin:P_FROM_DATE?><?$P_FROM_DATE?>
    this form date is coming from report parameter and is coming like this 2012/11/01 00:00:00.
    So now i need this in DD-MON-YYYY fromat.I tried like this <?param@begin:P_FROM_DATE?><?$format-date:P_FROM_DATE;'DD-MON-YYYY'?>
    but its giving error. Can any one pls tell how to convert it to customized date format.
    thanks & Regards
    Srikkanth.M

    Issue solved.
    Ref this link
    XML date Format

  • How to add new data entry and display old data in the same screen in SM30?

    Hi, Experts:
    We need to use SM30 to maintain a table entry. When I click the button of "New Entries", the table screen becomes blank. I can only add new data but not be able to see the old data existing in the table.
    How can I have the new line available for me to add new data at the same time see the data currently existing in the table?
    Thanks,
    Jenny

    Hi, thanks for the reply!
    Just to follow up for what we did to disable the delete function for maintaining table records. We hided the Delete button by adding a "MODULE disable_delete" code in Screen Painter. So now only adding records to the table is allowed.
    Thanks,
    Jenny

  • Nested Table: How to display formatted text in the form ?

    Hi,
    Scenario:
    I have a nested table, say TAB1, containing another table TAB2 which holds the formatted text.
    Sample data
    Entries in TAB1:
    Column1       Column2(TAB2)
    Text1         Data_from_tab2
    Text2         Data_from_tab2
    Text3         Data_from_tab2
    Requirement:
    The requirement is to display the data in TAB1 as it is maintained.
    Trials:
    I am aware of the fact that we can transfer the content of the nested table (in this scenario, TAB2) in another table(of type TLINE) defined as a global variable in the interface of the form. Then in the context area, we can define a 'TEXT' node and bind it to the table and choose the 'Dynamic text' for the 'text type' attribute and maintain the other atrributes.
    But this approach cannot solve the issue as it is a nested table.
    Kindly suggest how can I resolve this issue.
    Regards
    s@k

    Hi,
    if its like colum1, column2 (tab2).
    you can represent column2 as a nested table in the form. and put these tables structure intoa subform of type flowed.
    then you can have the required format.
    the same can also be acheived using nested subforms instead of tables.
    example of such scenario is PO & line items.
    po number1 , items 1
                          item 2
                          item 3
    po number2 , items 1
                          item 2
                          item 3
    hope this helps you.
    Cheers,
    Sai

  • How to retrieve the doc format data from the database?

    Hi Experts,
         I need to retrieve the doc files ( Cv's) from data base to my presentation server. In order to do that what is the field I can use?

    You can use officecontrol UI element for displaying doc files.
    below are some important links
    [Office Control|http://help.sap.com/saphelp_nw04/helpdata/en/5d/a0b16a9d2e4e4d8b2322af6728263f/content.htm]
    [example|http://help.sap.com/saphelp_srm40/helpdata/ru/ef/3483789514b748b6fe1f145e9685ab/content.htm]
    thanks
    sarbjeet singh

Maybe you are looking for