I think, that it will help you to create a new class for checking. 
I made the same ... check and then make registration save into DB ...

      <map:match pattern="user_registration">
          <map:act type="form-validator">
            <map:parameter name="descriptor"
value="context://validation/registration.xml"/>
            <!-- check action -->
            <map:act type="register-check">
                <map:call resource="xsp_page">
                        ... if the data are invalid, show XSP page
                </map:call>
              </map:match>
            </map:act>
            <!-- register new user, if data are valid and MAP is returned
from register-check action -->
            <map:act type="register">
                  ... <map:call resource="xsp_page"> ... </map:call>
            </map:act>
            <!-- in other case - if some problem occured -->
            <map:call resource="xsp_page">
              <map:parameter name="target" value="system_error"/>
            </map:call>
          </map:act>
        </map:match>
      </map:match>

JayKay

-----Original Message-----
From: Sheraz Sharif [mailto:[EMAIL PROTECTED]] 
Sent: Freitag, 07. Februar 2003 13:07
To: [EMAIL PROTECTED]
Subject: RE: DatabaseAddAction and unique or primary keys

I am using postgresql 7.2..

I am not sure what you mean.  Are you talking about making the database
run a trigger before the insert happens?  If so, I do not think that
will solve my problem.  I want cocoon to realize that there already
exists that specific value in the table, and notify the user to try
again. I think what I am trying to say is this.

1. User sends form to cocoon.
2. Cocoon processes form values.
3. Form values are ok, check the database to make sure primary keys and
unique keys do not already exist
4. on success, insert values into database
5. on failure, return failure

I am thinking that I need make some additions to the DatabaseAddAction
class to make this happen.

Sheraz

On Fri, 2003-02-07 at 05:43, Kazmir, Jaroslav wrote:
> Which type of database you use? Isn't it easily to use before insert
> trigger? 
> 
> JayKay
> 
> -----Original Message-----
> From: Sheraz Sharif [mailto:[EMAIL PROTECTED]] 
> Sent: Freitag, 07. Februar 2003 12:19
> To: [EMAIL PROTECTED]
> Subject: DatabaseAddAction and unique or primary keys
> 
> Hello all,
> 
> Sorry if this gets double-posted...
> 
> I have been working on a website for a while.  Here is my problem - I
> can easily verify user input through forms and return any error messages
> through the xsp-formval tags.  After validation, the input is passed to
> the database.  However, I get an SQL exception :
> 
> ProcessingException: Could not add record: java.sql.SQLException: ERROR:
> Cannot insert a duplicate key into unique index category_name_key
> 
> This is happening because I am attempting to insert a value into a key
> column where that value already exists.  I am looking for a solution
> where cocoon will connect to the database and attempt to retreive the
> key value before the insert.  If it does not exist, it will insert it,
> otherwise it will fail and I can notify the user of the error.  Have I
> been verbose enough?  If no solution exists, I am thinking I can either
> extend or rewrite the DatabaseAddAction class to do this.  Or should I
> abandon logicsheets all together and move to xforms?  Thanks.
> 




---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to