How do I set the response status code for a request in ADF?

For example:
I have a page accessible like page.jspx?id=$ID, in which $ID identifies an object stored in a database. The user navigates to page.jspx?id=abc. abc does not exist or has been deleted. I wish to set the response status code to 404 for the page request, like, for instance, https://docs.google.com/spreadsheet/ccc?key=abc does. How do I do this?
PS: Changing the status code for subsequent partial submits on the page if the object is deleted while the user is on the page (e.g. if the user attempts to delete an already deleted object through a "Delete" button on the page) may also be desirable, but would probably not fit in as well with the ADF lifecycle or be as useful.

Maybe I should be more specific about the current state of the code. It's something functionally similar in relevant portions to the following. For the purposes of this code, assume the ID maps only to a name, rather than a more complicated object:
page.jspx looks like:
<?xml version='1.0' encoding='utf-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
     xmlns:f="http://java.sun.com/jsf/core"
     xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
     xmlns:trh="http://myfaces.apache.org/trinidad/html" version="1.2">
     <jsp:directive.page contentType="text/html;charset=utf-8" />
     <f:view>
          <af:document binding="#{pageInitializer.dummyComponent}" title="#{pageData.name != null ? pageData.name : 'Object Not Found'}">
               <af:outputText rendered="#{pageData.name != null}" value="#{pageData.name}" />
               <af:outputText rendered="#{pageData.name == null}" value="No object was found at this URL." />
          </af:document>
     </f:view>
</jsp:root>pageInitializer and pageData are pageFlow-scoped beans with the following code:
class PageInitializer {
     @Inject private PageData pageData;
     @Inject private NameDao nameDao;
     @PostConstruct
     void initialize() {
          String name = nameDao.getNameById(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id"));
          if (name != null)
               pageData.setName(name);
          else
               // TODO: Set status code 404
     public void setDummyComponent(UIComponent dummyComponent) {
     public UIComponent getDummyComponent() {
          return null;
public class PageData {
     private String name;
     public String getName() {
          return name;
     public void setName(String name) {
          this.name = name;
}The code initializes the data from the database through the initilaizer of a pageFlow-scoped bean with a dummy setter for the document because I read somewhere that that would work, and it seems to work, even though it seems hacky.
Ideally, the code would render the 404 where it currently says (// TODO: Set status code 404). I realize this may not even be possible given the current architecture, because part of the response body has already been rendered, and I believe, but cannot find a source to cite, that the status code and headers cannot be set after the body has started being rendered. Is there any architecture that would get me this page's functionality (even if it's two JSPXs on the backend (which might be ideal)) and be able to render a 404 for an inexistent object?
Edited by: 907794 on Feb 1, 2012 3:55 PM
Edited by: 907794 on Feb 1, 2012 3:58 PM

Similar Messages

  • How do I set the default welcome page for PUBLIC user

    gurus,
    i'm using -
    Oracle 9i Database
    Oracle 9ias Portal Release 2
    QUESTION => how do I set the default welcome page for the PUBLIC user.
    i did the following to achieve this -
    1. logged into portal
    2. clicked on builder
    3. clicked on administer tab
    4. selected PUBLIC user in the Portal User Profile portlet
    5. went to the preferences tab
    6. in the default home page selected a custom page group
    7. logged out of portal
    8. open a new browsere session
    9. type the portal URL and i get the login page ....??
    i'm unable to understand this behavior ... shouldn't i be getting the page group that i set for the PUBLIC user in step 6 above ....
    the second QUESTION is => when the user logs out he/she should see the PUBLIC page set in step 6 above ... but, instead the user sees a page that is as follows -
    Partner Application Name Logout Status [Logout Status]
    Oracle Portal (portal) logout status
    The SSO Server (orasso) checkmark
    buzz.resva.trw.com:7778 checkmark
    infrastructure.happy.resva.trw.com checkmark
    portal1.buzz.resva.trw.com checkmark
    portal2.sylvester.resva.trw.com checkmark
    sylvester.resva.trw.com:7778 checkmark
    so, how can i set the default page for the PUBLIC user and also a page when he user logs out.
    ideas anyone ....?
    thanx a bunch.
    hero

    Hi,
    The sequence of operation you are doing to set the home page for public users is correct. You are getting the login screen as the "custom page group" selected as "home page" has not been granted to public.
    Also, while logging-out, it is normal behaviour to get the screen where it shows the list of partner applications from where user has been logged-out. When you click on "Return" button, you will get to the "home page" set above.
    Hope it clarifies the things.
    Regards,
    Ved

  • How do I set the default print margins for ALL printers in mozilla.cfg

    How do I set the default print margins for ALL printers in mozilla.cfg, even ones that are not yet installed / connected to the computer?
    I'm trying to install firefox with MDT and apply certain print options, but the printers themselves are connected at a later stage so the print.printer_myprinterhere cannot be used.

    Best answer I could find: [https://mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files/#comment-132668]
    If you can figure out how to add the printer name, this can be used to lock the margins.

  • How can I download the full source code for the Java 3D package

    how can I download the full source code for javax.media.j3d
    especially I need the Transform3D.java class.
    thanks a lot
    Meir

    thank you guys I'll try to do so, I suggest you to
    join me.From the one of the (ex-!)Java3D team:
    "I'm glad to see that Sun has decided to officially support an
    open source Java/OpenGL binding, JOGL. Perhaps they will
    eventually decide to make Java 3D open source. However, be
    careful what you wish for. The Java 3D source is huge and
    complex. There are native sections for Solaris, Windows/OpenGL,
    and Windows/Direct3D, plus common code. I don't know how you'd
    open source a build process that requires different pieces of
    the code be built on different machines running different
    operating systems."
    Sounds scary - I hope we're ready for it :)

  • How do I set the number of columns for JTextPane

    I only found a method setSize() of JTextPane class. How can I set the number of columns in a JTextPane? Each column can be written one letter.
    Thanks.

    You're not going to use FontMetrics to change the width of the characters; you're going to use it figure out how wide a single character is. Then multiply by the number of characters you want to have in a line, and presto! You know how wide to make your JTextPane.
    Unless I've misunderstood your problem, of course.

  • How can I set the default home page for all new users in Firefox 4

    I'm trying to deploy FF 4.0rc1 in a corporate environment but I can't find a way to set the default home page or any other settings for that matter.
    Is there a way to set the default home page for all new users and lock it so that the users can't change home page?
    Best regards
    Jonas

    In Firefox 4 the template folder for new profiles (C:\Program Files\Mozilla Firefox\defaults\profile\
    ) doesn't exist. You can create that \defaults\profile\ folder and place a file user.js in it with the prefs that you want to initialize.
    See:
    *http://www-archive.mozilla.org/catalog/end-user/customizing/briefprefs.html
    You can also use a mozilla.cfg file to set the default value for prefs.<br />
    See: http://kb.mozillazine.org/Locking_preferences
    defaultPref(); // set new default value
    pref(); // set pref, but allow changes
    lockPref(); // lock pref, disallow changes

  • How can i set the IDOC Status to 03 without doing a "COMMIT WORK"

    Hello Geeks,
       I want to set the status of the Outgoing IDOC to 03 , without doing a "COMMIT WORK" . Actually only after i do a commit work are my IDOCs dispatched. But with a commit work the IDOCs are dispatched immidiately. I do not want to dispatch it immidiately. Instead i want to hol the IDOCs till my LUW finishes , but the IDOC status should be set to "03" instead of "30".
    Thanks,
    Bashir

    Hi,
    After collecting all the idocs which are under status 30, run the program RSEOUT00 to change the status from 30 to 03.
    If you want to do this process automatically then set the program RSEOUT00 in background.
    Regards,
    Lokeswari.

  • How do I set the DVD region code via ARD?

    We recently deployed around 200 MacBooks in a k12 environment and manage them via ARD & WGM. We forgot to set the DVD region when creating our master image and as a result, every single MacBook prompts for an admin password when attempting to use the DVD Player to view a DVD for the first time.
    Instead of attending to each of the 200+ MacBooks personally and putting a DVD in and setting the region code one by one, is there a way I could do this via ARD? Unix command? Managed preference via WGM? Thanks, I appreciate any input.

    I've been working on this very topic for about a year. Here's what you need to know.
    1) setting the region code on your master image would result in the same behavior. Setting the region code triggers an update to the DVD drive firmware itself - it's not something that's stored in software. Obviously this is something that needs to be set on each machine individually. Setting it on the image won't affect the imaged-machines.
    2) Apple seems to have gone to great lengths to hide the app that triggers this action. If they had provided a simple CLI interface to trigger this on a client machine we'd be able to use ARD to trigger the action on all of our client machines. Alas, this app is buried somewhere I can't find and seems to only rear its head when a DVD with a region code is inserted into the drive. There is one idea that popped into my head while at Macworld that I want to try to see if I can find this app but I have my doubts.
    3) Failing my last ditch effort to find this app, I think our fallback will be to give users explicit rights to set the initial DVD region code on thier machines. This is something that can be done using WGM. There is a rule in /etc/authorication specifically allowing users/groups to set the region code for the first time. According to the notes, giving this access will NOT allow users to change the region code - which is a good thing - but only give them rights to do so the initial time. This way, we can empower our users to help themselves while also protecting them from resetting the region code accidentally.
    In conclusion, I haven't found any way to script/push this command to a client machine. I'll definitely file this with Bug Reporter and hope Apple will give us a CLI or an ARD command to trigger this action after imaging.
    G4   Mac OS X (10.4.8)  
    G4    
    G4    

  • How do I set up a lock code for my Nokia C2-02?

    Hi, I have a used Nokia C2-02 phone from a seller on eBay.
    I wish to protect my privacy so that other people cannot access my texts, etc.
    When I go to 'settings', 'security', and click on 'access codes', in order to set up a lock code,  the display says'change security code'.
    When I ckick on it, I get a request for my security code.
    Twice now I have keyed in'12345', which I take to be the default code.
    Each time I get an error message and the second time it said that I have only one more chance to key in the correct code.
    Perhaps the previous owner had a code, which I take to be the same as a security keyguard code.
    When I go to 'device' in 'settings', it says that the security keyguard is off.
    I can switch it on, but to activate it I again need to key in a code.
    Am I corect in thinking that either someone has alrerady set up a code or the default code is not '12345'?
    Also, What can I do to set up my own code?
    Fianally, What if I use a pin code? Will that protect my privacy?
    Do I have to get in touch with my network provider ( Tesco Mobile) in order to set it up?
    I'd appreciate any help anyone can give,
    Laurence
    Solved!
    Go to Solution.

    If I used a  pin code instead, would it protect my privacy?
    would it stop those without the code reading my texts and so on?
    PIN Code is basically for the SIM card and not the phone. Talking of privacy, your phone will be fully explorable if the SIM card is removed, so PIN scenario is pretty wasteful. Majority of the phones only ask for the PIN code when the phone is started and register the SIM to the network only wen PIN is furnished.
    If It does not work I could find that I have locked the phone, which could necessitate sending it to the Nokia Care centre.
    This is where the online free service may come in. It claims that it can find the security mastercode for any individual phone, based on the IMEI number, which you access by keying in asterisk, hash, 06, hash, or by taking the back off the phone and looking inside.
    Armed with the 10-digit mastercode you key it in and it unlocks the phone.
    That, at least, is the claim, but on another mastercode site there's a warning that the mastercode works only for older models.
    I have my mastercode, but I don't know whether to take the chance.
    Does anyone have any views on this?.
    , Cheers, Laurence
    Unfortunately, these type of Master Codes do not work. If ever they worked, the phones would become too easy to break in. As far as I can remember, I have not seen any person with a claim that one of those Master Codes worked for them. Maybe they worked for very very old 1st gen devices from Nokia, but not anymore. The security code is based on what user enters in the settings and there doesn't exist any master code to over-ride that. If it would, Nokia Care should be making use of that instead refurbishing/flashing the phones in every case that called for Keyguard Code.

  • How do you set the time and date for the fax on the HP Office Jet 4622 All-in-one Printer?

    I installed the HP Office Jet 4622 All-in-one Printer and everything works wonderfu.  However on the test page for the fax the time and date are showing Jan-00-00 00:00AM.  I do not know how to change the date and time.  Please help.  Thanks.
    This question was solved.
    View Solution.

    Use the Setup (wrench icon) button on the front of the printer to look through the settings menu to set the printer time and date.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • How can I set the default save format for photoshop edited photos?

    I just spotted that some of my photos that I've edited in Photoshop from Lightroom are a whopping 450MB. Looking deeper I found that they are saved as uncompressed TIFF files, this despite the default save format for Photoshop in Lightroom's preferences being set to ZIP compressed TIFF files. So why doesn't this setting work and how can I make Photoshop save things compressed?

    Sounds funny but first tell us what version of PS you have, what version of Lr and which OS. Thanks.

  • How do I set the default startup sequence for iWork documents under mountain lion?

    I am frustrated when starting Pages under Mountain Lion (OSX 10.8.2). Instead of opening with the documents that I was working on when I closed the app, it opens with a standard "open" dialog box. I am forced to navigate through my folders and files or "create a new document" and then go to previously opened files. I would like Pages to open in the same status it was when I last used it, or if no files were open, to then automatically "create a new document" using the "Blank" template. In other words, how do I open Pages directly without the intervening dialog boxes?

    Open General preferences and uncheck these boxes:

  • How do I set the about:config settings for all users? iprism keeps prompting from authentication for users.

    When users log on and try to open Firefox 23.0.1, users are prompted with Iprism Authentication. We made changes to the firefox about:config values "network.automatic-ntlm-auth.allow.-non-fqdn" and "Network.negotiate-auth.allow-non-fqdn" to true and it works, but only works on a per user basis. How can we set this up for all users?

    I would think the about:config entries discussed are ex-factory set to values each user has to change individually, after the installation has run its course. The solution could be to have patched files ready to install post factum:
    [https://developer.mozilla.org/en-US/docs/Mozilla/Preferences/A_brief_guide_to_Mozilla_preferences A Brief Guide to Mozilla Preferences - MDN]

  • How do you get the trade in code for the $100 gift card?

    On January 28, I activated a Samsung S4 that I had mail ordered from Verizon Wireless.  I went to the online chat service to find out about the $100 trade in for my functioning Moto Bionic, and after some back and forth, was told that they could not help me and I had to call customer support.
    I generally prefer not to call because of the waiting time, but on several of my calls on this I have actually gotten through fairly quickly (i.e. under five minutes of wait).  So, on the first call, I was told to fill out the form on the trade in page using the code "Smart100" where required the online form.  The "Smart100" code did not work (and I tried various permutations, including initial cap, initial non-cap, space, no space, underscore_connect, all with no success). 
    I called back to inquire why "Smart100" did not work, and after the CSR explained case sensitivity to me (and I explained all the permutations that I had already run through before calling back), we agreed that Smart100 was just not going to work.  She then went to find further information.  She returned to the line to advise me that, indeed, Smart100 would not work, but that Verizon would send my phone a text of the code to enter on the trade in page within five calendar days of activation of the new phone. 
    I called on the sixth day, and I spoke to another CSR.  She told me that the five calendar days was inaccurate, and the code would arrive on my phone within five business days. 
    I waited until COB on the fifth business day , and called again.  However, the CSR (accurately) pointed out out that it was not yet midnight, and  the code would surely arrive that evening. 
    Unfortunately, I still (some 2 1/2 weeks after activation) do not have the code.  I have decided to try a different approach, to wit, a posting here. 
    Suggestions?

    For whatever it's worth, I received an email back in the same day from the "Wireless Device Recycling Team" with a code that went through.  I am not sure who the Recycling Team is, but this was a very positive experience after the frustrations of talking and chatting with CSR's who, while trying hard, were not well informed about this particular issue, so hats off to the Recycling Team.

  • How do I set the default file path for the Place command?

    I keep my graphics files for each document in a particular folder. Every time I open an existing InDesign document and place a new image I have to browse back to that location - even though all of the previous images in that document came from the same folder. InDesign does not remember the file path that was used previously in the document. This is very annoying.
    IS THERE A WAY TO SET THE DEFAULT FILE PATH, OR LOCATION, FOR IMAGE FILES?
    I have looked through the preferences, searched the forums and internet, but I have not found any reference to setting default paths. Is there a setting like the one in MS Word called "File Locations" on the Options toolbox?
    Thank you.

    Since you're working in ID on Windows, you can take advantage of a neat trick in Windows. Copy the file path out of the File Explorer address bar and paste it directly into the Place filename field. That will jump you directly to the desired volume. For example, let's say I want to place a graphic located at X:\PS Jobs\May PS\709672bp\Working Source Files\Links. I copy that entire path from the File Explorer address bar, go to InDesign, select File|Place, and press Control + V to paste that path into the filename field. I press the Open button and Shazam! I'm there instantly, without a bunch of navigation.
    You can do the same thing in the File|Save As and File|Export fields. Let's say you want export a PDF file from InDesign to the volume X:\PS Jobs\May PS\709672bp\Working PDF Files. First copy the desired file path from the File Explorer window. In InDesign, select File|Export, click anywhere in the filename field, and press the Home key to move the insertion point to the front of the filename. Press Control + V to paste that path in front of the filename, then add the backslash character (\). The filename will now look like this: X:\PS Jobs\May PS\709672bp\Working PDF Files\Filename.pdf. Press the Save button to bring up the Export Adobe PDF window. Select your desired PDF preset, press the Export button, and the PDF file will magically appear in the desired volume.
    This sounds really complicated, but it's not. In practice, it only takes a few seconds. I probably save an hour's worth of needless navigation every day with this technique.

Maybe you are looking for