JSF and Database Validation

I would like to perform validation that seems to be a little involved with JSF and I was curious as to the best practice. I need to perform validation on a summary screen where the user can highlight a row and click an Edit button that takes them to another screen. However, I need to query the database when they click edit to check to see if the item they selected is able to be edited (these rules are part of our business logic). What is the best way to perform database-side validation using JSF? If I query the DB in the action event of the command button, how can I then inform the JSP if the item fails validation and then display a message from messages. properties? Keep in mind that an item can fail validation for a number of reasons, so the message could be different each time the validation is performed.

You have two choices:
a) Don't let the user edit the line, by don't allowing the he to have an action on that row.
b) If you have a global command, then perform the validation on the action method.
In the a) case, you only have to put some flags to tell the page to not put the command on the row. This flags came with the query or whatsoever that you like more.
In the b) case you can perform the validation by calling the business logic, and in case of failiure, you can add a message to the FacesMessage tellong the user the reason of not allowing he to edit.
Example (on the bean):
FacesContext.getCurrentInstance().addMessage(componentId,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
errorMessage,
errorMessage));
The componentId can be null or of not, the id of a component on the page.

Similar Messages

  • JSF and Database tables in the pages...

    Hi guys,
    I am following this excellent tutorial http://www.oracle.com/technology/oramag/oracle/06-jan/o16jsf.html as I am learning JSF using JDeveloper. Unfortunately since my knowledge of JDeveloper and JSF being rather limited, there is one section in the tutorial that I am unable to understand. If you do a search on that web page and type in 'column1' without the quotes, I am unable to understand where the author got that object from.
    Barring that I also had another question. I just saw a demo video of Netbeans taking the Entity beans generated from the database tables and creating JSF pages based on the tables with one click that showed the data very nicely in a table format in the jsp page. Is there some sort of functionality like that? Or is that JEE 5 specific? Also is JDeveloper JEE 5 compliant as of yet?
    Sorry for the laundry list of questions.
    Surya

    Before I make an even bigger fool of myself in this forum, the tutorial has 2 parts. Does part 2 depend on part 1 to get it working right because I feel as if I am missing something.
    Also it seems that for however many columns we are able to retrieve from our ResultSet we should know beforehand so we can code up the DataTable. This might not be the case all the time I guess, so is that where the JSF support in the ADF framework comes in and makes life a lot easier for the developer?
    Thanks for answering all my questions.
    Surya

  • Jsf and database access running in tomcat5

    hi all
    I have my JSF application saved on the "webapps/buydirect" directory in the tomcat container.
    I'm trying to call my first page(index.jsp) but no responce.
    is there any setting to be done before running the application? and which path do I have to use?.
    please halp
    thank you

    post your faces config file and your web.xml file.

  • JSF and Database

    Please help me to understand how we use JSF to get data from database like oracle ,my sql.
    Thanks in advance

    inserting
    import java.sql.*;
    import java.util.Date;
    import java.io.*;
    public class InsertBean {
    private String url = "jdbc:mysql://localhost/mysite";
    private String driver = "com.mysql.jdbc.Driver";
    private String user = "root";
    private String pass ="root";
    private Connection conn;
    private String name;
         private String last_name;
         private String email;
         private String birth;
         private String password;
         private String sex;
    private String confirm;
    public String getBirth() {
    return birth;
    public void setBirth(String birth) {
    this.birth = birth;
    public String getEmail() {
    return email;
    public void setEmail(String email) {
    this.email = email;
    public String getLast_name() {
    return last_name;
    public void setLast_name(String last_name) {
    this.last_name = last_name;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    public String getPassword() {
    return password;
    public void setPassword(String password) {
    this.password = password;
    public String getSex() {
    return sex;
    public void setSex(String sex) {
    this.sex = sex;
    public String doInsert() throws ClassNotFoundException, SQLException {
    Class.forName(driver);
    conn = DriverManager.getConnection(url, user, pass);
    PreparedStatement st = null;
    Statement s = conn.createStatement();
    st = conn.prepareStatement("insert into register (name, lname, password,email, birth) values(?,?,?,?,?)");
    st.setString(1, name);
    st.setString(2, last_name);
    st.setString(3, password);
    st.setString(4, email);
    st.setString(5, birth);
    int i = st.executeUpdate();
    conn.close();
    return "success";
    }

  • Where to find how to use JSF and database operation(eg. JDBC) together?

    Thanks very much!

    Hi zhouen & Andrea,
    Actually you should avoid using the SQL tags for antyhing but a trivial application.
    I previously posted on this topic here;
    http://forum.java.sun.com/thread.jsp?forum=427&thread=418247&message=1851795#1851795
    and here;
    http://forum.java.sun.com/thread.jsp?forum=427&thread=435179&message=1957499#1957499
    And as Craig noted in his follow up to the first post it is very important to separate your business logic from the view.
    Basically your application will be hard to maintain and extend if you embed access to the databse in your JSP's. For example, consider a search page. If you embeded the SQL into a JSP the app could be made to work, but consider a late breaking requirement 'we need to access the search functionality from a webservice'. How would you accomplish such an extension if the SQL was in the page. Hard to do at best.
    TTFN,
    -bd-

  • Building a Simple JSF and Web Services App in JDeveloper 10.1.3 Preview

    Hi
    I was trying out this example of JSF and webservices at:
    http://www.oracle.com/technology/products/jdev/101/howtos/jsfws/index.html
    Has anyone tried it before? I'm getting the following error:
    calling http://216.200.21.157:9090/soap
    WARNING: Unable to connect to URL: http://216.200.21.157:9090/soap due to java.security.PrivilegedActionException: oracle.j2ee.ws.saaj.ContentTypeException: Not a valid SOAP Content-Type: text/html
    java.rmi.RemoteException: ; nested exception is:
         HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: oracle.j2ee.ws.saaj.ContentTypeException: Not a valid SOAP Content-Type: text/html
         at com.minc.ws.stockquery.proxy.runtime.NetXmethodsServicesStockquoteStockQuoteBinding_Stub.getQuote(NetXmethodsServicesStockquoteStockQuoteBinding_Stub.java:96)
         at com.minc.ws.stockquery.proxy.NetXmethodsServicesStockquoteStockQuotePortClient.getQuote(NetXmethodsServicesStockquoteStockQuotePortClient.java:40)
         at com.minc.ws.stockquery.proxy.NetXmethodsServicesStockquoteStockQuotePortClient.main(NetXmethodsServicesStockquoteStockQuotePortClient.java:29)
    Caused by: HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: oracle.j2ee.ws.saaj.ContentTypeException: Not a valid SOAP Content-Type: text/html
         at oracle.j2ee.ws.client.http.HttpClientTransport.invokeImpl(HttpClientTransport.java:142)
         at oracle.j2ee.ws.client.http.HttpClientTransport.invoke(HttpClientTransport.java:118)
         at oracle.j2ee.ws.client.StreamingSender._sendImpl(StreamingSender.java:175)
         at oracle.j2ee.ws.client.StreamingSender._send(StreamingSender.java:112)
         at com.minc.ws.stockquery.proxy.runtime.NetXmethodsServicesStockquoteStockQuoteBinding_Stub.getQuote(NetXmethodsServicesStockquoteStockQuoteBinding_Stub.java:79)
         ... 2 more
    Any ideas?
    Thanks
    Alex

    I'm not using 10.1.3 preview. I was using 10.1.3.1 production. I just copied the title of the tutorial as my subject. sorry for the confusion!! :)
    I used the HTTP analyzer and this is what I got in the header:
    <HTML><HEAD><TITLE>TCP Packet Monitor Error</TITLE></HEAD><BODY>JDeveloper TCP Packet Monitor encountered an error retrieving<P><pre>POST http://216.200.21.157:9090/soap HTTP/1.1
    Host: 216.200.21.157:9090
    Proxy-Connection: Keep-Alive
    Connection: TE
    TE: trailers, deflate, gzip, compress
    User-Agent: Oracle HTTPClient Version 10h
    SOAPAction: "urn:xmethods-delayed-quotes#getQuote"
    Accept-Encoding: gzip, x-gzip, compress, x-compress
    Content-type: text/xml; charset=UTF-8
    Content-length: 680
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="urn:xmethods-delayed-quotes"><env:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" env:mustUnderstand="1"/></env:Header><env:Body><ns0:getQuote env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><symbol xsi:type="xsd:string">orcl</symbol></ns0:getQuote></env:Body></env:Envelope></pre><P>The error was :<P><pre>IOException retrieving the response: java.net.ConnectException: Connection refused: connect</pre><P></HTML>
    It looks like I'm getting connection refused error... Hmmm.. wonder why?
    I'll download 10.1.3.2 and see if that helps..
    Thanks for looking into this!
    Alex

  • JSP, JSF, and ADF

    I've just started playing around with this and was looking for samples/tutorials to help. Of the tutorials/samples I've seen, they appear to fall short of explaining an end-end example and stick mostly to JSF and the backing bean - usually displaying static data within a JSP and navigation. I'm a bit confused on how to call custom methods in my business services (application modules) and in turn use the view objects to fetch data from my database and display the results within a JSP using the JSF components.
    I realize the latest preview JDeveloper is without ADF but while I had time I was hoping to play around with ADF Faces to hit my development database. Guess I'm trying to make sense of how JSP, JSF, Business components, and my db connection all play together in order to set up a decent starting point for an app.

    You could use Jdeveloper 10G and play around with ADF Faces, look at the demos, and the sources behind them.
    There are a couple of papers on OTN like...
    Working with ADF Faces in JDev 10g:
    http://www.oracle.com/technology/products/jdev/howtos/10g/adfjsf/how-to-adf-faces-10gjdev.htm
    Roadmap for ADF Faces:
    http://www.oracle.com/technology/products/jdev/collateral/papers/9.0.5.0/adfuix_roadmap/adfuix_roadmap.html
    And many more... as I could find upon search...
    http://www.oracle.com/ultrasearch/wwws_otn/searchotn.jsp?p_Action=Search&p_Query=adf+faces
    The visual editing support for 'The ADF Model access through ADF Faces bindings' is under development (hence no tutorials), and will be available in future release (could be post 10G release).
    -Udupa

  • How to persist parent  and child tree node data through JSF and Hibernate

    Dear dudes,
    I'm a novice to JSF and Hibernate
    Actually i want to create a tree structure where for each child node, i should have the parent node reference in my form and then when i save, i need to save the corresponding child node data in the database.
    node-1
      node 1-1
         node 1-11a
      node 1-2
    node-2
       node 2-1
       node2-2Whenever i click node 1-1 the corresponding parent node ( node-1) reference should appear in my form and when i save this data this data should be saved under parent node and the tree should be re-rendered.
    How this can be accomplished and if there are any URL's please refer.

    Everybody need not face the same problem you faced. And moreover, everyone out here have their own issues to solve. If people are helping out here, its cause of their passion. Please try to be polite.
    First of all, what is that you have tried on the issue? Could you please share your work so that we can try to fill the gaps?

  • How do i show a popup in an OA Pageon the basis of some database validation

    Hi All
    I need to show a popup message on the click of a button.
    On the click of the button I have to submit the page and do some database validation with the data entered by the user on that page.
    Depending on the validation I have to give a popup which will have a value that is fetched from tha database.
    I can show a popup by writing the below given code in the processRequest of my CO
    OASubmitButtonBean registerbutton = (OASubmitButtonBean)oawebbean.findChildRecursive("RegisterButton");
    registerbutton.setOnClick("alert('show an alert')");
    But I cannot perform the database validation(using a stored procedure) in the processRequest.
    I am performing the validation in the processFormRequest
    Also I am not able to show the value fetched from the database in the popup using the above alert.
    Please send me the code.
    Thanks in advance.
    Regards
    Meenal

    okay so the popup window would be some information window, where the user, maybe after reviewing the information presses close and closes the window.
    i would do this using PPR, have a small content region or some other small region(which supports PPR), which would showup in some section of the screen when the user performs the desired action, and have a close button in the region, pressing close would fire PPR again and hide this region.
    There maybe variety of solutions such as this depending on the requirement.
    Thanks
    Tapash

  • Clarrification about JSF and JBoss Seam

    Hi ,
    i have just started a couple of hours ago reading about JSF and JBoss Seam and it seems interesting ......
    here is my question :
    i have a form ( registration form ) written in jsp and a congratulation page (jsp page too)
    is right what i am saying ?
    JSF form ( input values) are sent to Seam to be validated under hibernate rules and then it( Seam ) responses to the JSF the entity bean .
    again JSF form asks Seam to resolve the variable Register ( the value of the submit button in the form) and Seam returns the RegisterACtion
    After that the same jsp page invoke the register method of the RegisterAction stateless session beam .inside the register method it redirect the user to congratulation jsp page .
    do you think its correct
    sorry folks for my english
    Best reagrds
    yacine fandi

    or maybe if you can give a link of a good tutorial I�ll be greatfull
    cheers yacine
    Message was edited by:
    fandi_yacine

  • JSF and JSTL integration

    Can anyone tell me how to access JSF objects from JSTL tags?
    I want to set a requestScope flag in my changeListener
    ... context.getExternalContext().getRequestMap().put("xxx","ok"); ... and render output depending on existance of this flag:
    ...<c:if test="${requestScope.xxx!=null}" > .... .
    This examplecode doesn't work, JSTL tags cannot access this var! How can I do that?
    What I realy want is to reload another frame when user changed a specific input field.
    Above code should add a JavaScript to reload the frame if this is true .
    I can't do this on submit because the other framepage uses the stored/modified data.
    Maybe there's a better approach for this anyway?
    Thanks for your help!

    Thanks for your help - I found it was my own mistake why it didn't work. Now it does, as you said.
    But in the meentime I ran into another Problem mixing JSTL und JSF:
    I want to build a SelectOneMenu and populate it with data from a database, but with selectItemValue
    other than selectItemLabel (value should be numeric DB-ID, label a readable name).
    Since "selectItems" allows only one dimensional Arrays (?) as parameter, I must use "selectItem" for
    each row. So I wrote following code:
    <h:selectOneMenu id="m1" value="#{worktime.employee}">
       <sql:query var="employees" dataSource="jdbc/WebOfficeDB">
           select oid,displayname from employees order by displayname asc
        </sql:query>
        <c:forEach var="row" items="${employees.rows}" >
           <f:selectItem itemValue="#{row.oid}" itemLabel="#{row.displayname}" />
        </c:forEach>
    </h:selectOneMenu>This doesn't work, I get NullPointer Exceptions from selectItem.setValue().
    I think because JSF "#" references another context than JSTL "$" - is this correct?
    So I tried to set a JSTL variable inside the forEach loop to access the datarow
    <c:set var="data" value="${row}" scope="request"/>
    <f:selectItem itemValue="#{requestScope.data.oid}" itemLabel="#{requestScope.data.displayname}" />
    ...The effect is that all lines of the selectOneMenu have the same content (from the last datarecord)!?
    Since this is my first project in JSTL and JSF and should stay a small one I don't want to go into building
    CustomComponents and so on for such a simple Task.
    I would be very very happy for some tips and hints, since I think this mixing of JSTL and JSF Context
    will be a very common problem within my project.
    Thanks

  • Database Validation Failed error while configuring RDBMS profile for audit

    Hi,
    I am using Oracle Access Manager 10.1.4.3.0 with FMW 11g (Oracle internet Directory and Oracle Virtual Directory) on Linux X64.
    While configuring RDBMS profile for OAM Auditing and reporting...
    I am getting "Database Validation Failed" error both in Identity and Access servers
    When I am looking in oblog...I got following in Identity..
    2010/07/17@06:59:28.882658     17384     17422     CONNECTIVITY     DEBUG3     0x00000201     obmessagechannel.cpp:179     "Sending: "     seqno^13     opcode^8     pMsg^{25}st={5}ma=22{4}mi=2{4}sg=0{4}rt=0     
    2010/07/17@06:59:28.882704     17384     17422     NET     DEBUG3     0x00000201     obsocket.cpp:848     "ObSocketOIS::WriteFully"     _sock^19     LocalAddr^10.31.13.129     LocalPort^6022     RemoteAddr^10.31.13.134     RemotePort^41646     
    and in Access..
    2010/07/17@06:39:09.391459     3326     3388     AUDIT     ERROR     0x00001D04     ../dbauditwriter.cpp:410     "The database audit writer was unable to perform the write"     
    2010/07/17@06:39:09.391491     3326     3388     AUDIT     WARNING     0x00001149     /usr/abuild/Oblix/10143hf/palantir/aaa_server/src/audit_handler.cpp:1119     ""Unable to write the audit record"
    Kindly advice...

    Hi.
    Strange !
    Check whether the RFC destiantion LCRSAPRFC is proper. Test the connection and Also check the exchange profile paramteres in the XI.
    Also refer
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c6/6f1741b393f26fe10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/f4/67b340be3dff5fe10000000a155106/frameset.htm
    Also check what user is maintained via transaction SLDAPICUST. and carefully enter the password, also check that if user is locked.
    Hope this will help you a bit.
    Regards
    Aashish Sinha

  • I want to create a login form by using servlets with database validation.

    Would you please provide me a code for a login form using servlets with Ms Access database validation?

    No. This is not a free coding service. Your request is (a) ridiculous, (b) offensive, and (c) off-topic. Locking this thread for later deletion.

  • OAM:Database Validation Failed While Trying to Add New RDBMS Profile

    It's about DB connection with OAM 10.1.4 through OCI in Windows Server 2003.
    The error in OAM identity console: Database Validation Failed
    The error in OAM component logs: TNS:could not resolve the connect identifier specified%0a Error Code from OCIErrorGet^12154
    My working environment is 'Integrated IDM 10.1.4' downloaded in FF, the following is its description:
    This image is based off the OIM 9.0.3 image built by Sanjay Rallapalli. The underlying environment on which the image is built includes the following component and any associated user name/password combinations:
    Windows 2003 Active Directory (Administrator/abcd1234)
    Exchange 2003 (Administrator/abcd1234)
    Sun One Directory Server (cn=Directory Admin/abcd1234)
    Microsoft IIS
    Microsoft Certificate Authority
    Tomcat J2SE Server
    The image also includes a number of Oracle components including:
    Oracle DB 10G (sys, system/abcd1234)
    Oracle OC4J (http://ten.mydomain.com:7777/em oc4jadmin/abcd1234)
    Oracle Identity Manager (xelsysadm/xelsysadm)
    Oracle Virtual Directory (cn=admin/abcd1234)
    Oracle Access Manager (Administrator/abcd1234)
    Owner: Michael Terra     Creation Date: 24-JUL-08     Rating: Not Rated
    VM OS: Windows Server 2003     
    It seems an old problem as there are many articles in metalink treating it.
    Although I tried every solution proposed by metalink, I still get my 'Database Validation Failed'. I have restarted my system and rechecked in metalink several times.
    I'd like to know is there anyone who has successfully configured OAM connecting with Oracle DB through OCI in Windows? Could you tell me is there anything special I have to do? Thanks a lot.

    Hi All,
    I am trying to configure the audting for OAM 10.4.0.1 with OID as user store/Policy store. My oracle DB (10.1.0.5.0--comes bundled with OID) is on same host.
    I am trying to configure the audit database in OCI mode as there is some issue with installation of ODBC driver that i was not able to resolve.
    While creating RDBMS profile i am also getting the same error *"Database validation failed*" and in identity server logs stated as "*SqlAdapter Error OCIerrormap cpp:53 'OCI failed to create environment variable' method^OCI Adapter::OCI Adapter ociRetcode^ OCIError"*
    Does anyone able to successfully configure the audit database with same environment or let me know where i am missing or additional steps required.
    Thanks in advance!

  • Re: what is difference between sap locking and database locking

    hi,
        what is difference between sap locking and database locking. Iam locked the table mara by using lock objects.
    But iam unable to unlock the mara table. I give u the coding. Please check it.
    REPORT zlock .
    CALL FUNCTION 'ENQUEUE_EZTEST3'
    EXPORTING
       MODE_MARA            = 'S'
       MANDT                = SY-MANDT
       MATNR                = 'SOU-1'.
    call transaction 'MM02'.
    CALL FUNCTION 'DEQUEUE_EZTEST3'
         EXPORTING
              mode_mara = 'E'
              mandt     = sy-mandt
              matnr     = 'SOU-1'.
    IF sy-subrc = 0.
      WRITE: 'IT IS unlocked'.
    ENDIF.

    Hi Paluri
    Here is the difference between SAP locks and Database locks, i will try to find the solution to your code.
    Regards
    Ashish
    Database Locks: The database system automatically sets database locks when it receives change statements (INSERT, UPDATE, MODIFY, DELETE) from a program. Database locks are physical locks on the database entries affected by these statements. You can only set a lock for an existing database entry, since the lock mechanism uses a lock flag in the entry. These flags are automatically deleted in each database commit. This means that database locks can never be set for longer than a single database LUW; in other words, a single dialog step in an R/3 application program.
    Physical locks in the database system are therefore insufficient for the requirements of an R/3 transaction. Locks in the R/3 System must remain set for the duration of a whole SAP LUW, that is, over several dialog steps. They must also be capable of being handled by different work processes and even different application servers. Consequently, each lock must apply on all servers in that R/3 System.
    SAP Locks:
    To complement the SAP LUW concept, in which bundled database changes are made in a single database LUW, the R/3 System also contains a lock mechanism, fully independent of database locks, that allows you to set a lock that spans several dialog steps. These locks are known as SAP locks.
    The SAP lock concept is based on lock objects. Lock objects allow you to set an SAP lock for an entire application object. An application object consists of one or more entries in a database table, or entries from more than one database table that are linked using foreign key relationships.
    Before you can set an SAP lock in an ABAP program, you must first create a lock object in the ABAP Dictionary.

Maybe you are looking for

  • MTS not to consider open PR,PO and quality stock

    Dear all, my client wants for MTS scenario system not to consider Stock of RM for  Open Purchase order, Open PR and Quality Stock at the time of MRP run for SFG and FG. I tried in SPRO settings also in OPJJ( availability check - 02 and checking rule 

  • AT&T Phone Reception is Terrible. Way to improve it?

    I know that the new iPhone comes out today. The big sell is the 3G, for better WiFi. What about the actual phone use? I don't know about anyone else, but I've had more dropped calls or "No Service" readings on this phone than any other service. I liv

  • Pics on my nano

    I have tried to upload pics to my nano without any luck. I keep getting the error "cannot read or write to the disk". Has anyone had this problem and if they did how did you solve it. Also is there a way to contact apple to just ask support questions

  • S1000 Data file size limit is reached in statement

    I am new to Java and was given the task to trouble shoot a java application that was written a few years ago and no longer supported. The java application creates database files the user's directory: diwdb.properties, diwdb.data, diwdb.lproperties, d

  • Fan Control and Leopard

    While I am happy with Leopard, it killed my Fan Control - now I face a roasting each time I use my MBP. Anyone know if this little gem will be updated for 10.5? Fan speeds of 1500rpm just don't cut it with a Core Duo.