You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Christian Helmbold <ch...@yahoo.de> on 2009/05/19 09:15:19 UTC

How to validate unique constraint?

How can I validate a unique constraint with Wicket? Because only the value of an input field is passed to onValidate(IValidatable validatable), there is no chance to check if this value belongs to a specific object to update or if it would violate a unique constraint when creating a new object. onValidate would need another paremeter for the related object.

I see two possibilities:

a) Use a form validator and get the related model object from the form.

b) Pass the related object to the constructor of the Validator. I'm not sure, if the validator would be recreated any time the model object changes.

I would prefer a validator tied to the field and not to the form, because that would be more intuitive.

Another idea is to use existing JPA annotations. @Column(unique=true) is already there but not used for validation (outside the database). Perhaps there is a way to use this annotation. I really like the domain level validation of Grails: http://grails.org/doc/1.1/guide/7.%20Validation.html

How would you validate a unique constraint with wicket?

Thanks in advance
Christian



      

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxEditableLabel within a RepeatingView?

Posted by Igor Vaynberg <ig...@gmail.com>.
just like you would use it outside a repeatingview...

-igor

2009/5/25 Dorothée Giernoth <Do...@kds-kg.de>:
> Hey everyone,
>
> how can I use AjaxEditableLabel within a RepeatingView?
> Meaning: I have data from a database written into a RepeatingView. Now I wanna make it possible, that the user can edit the cells.
> But how?
>
> Any hint would be appreciated.
> Thnx,
> dg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


AjaxEditableLabel within a RepeatingView?

Posted by Dorothée Giernoth <Do...@kds-kg.de>.
Hey everyone,

how can I use AjaxEditableLabel within a RepeatingView?
Meaning: I have data from a database written into a RepeatingView. Now I wanna make it possible, that the user can edit the cells.
But how?

Any hint would be appreciated.
Thnx,
dg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


AW: MarkupException, BUT WHY???

Posted by Dorothée Giernoth <Do...@kds-kg.de>.
I solved the problem myself.
- dg

 

-----Ursprüngliche Nachricht-----
Von: Dorothée Giernoth [mailto:Dorothee.Giernoth@kds-kg.de] 
Gesendet: Montag, 25. Mai 2009 11:41
An: users@wicket.apache.org
Betreff: AW: MarkupException, BUT WHY???

Oh yeah, that might be helpful:
Here is the exception message:

WicketMessage: Unable to find component with id 'heading' in [MarkupContainer [Component id = _extend3]]. This means that you declared wicket:id=heading in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/C:/workspace/MyApp/context/WEB-INF/classes/myapp/dbtest/ListTabelle.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/postage.css">
<title>Datenbank-Designer</title>

</head>
<body>
<div wicket:id="feedback"></div>
<p>Willkommen beim DB-Designer 1.0! (c) by dg</p>
<p><b>Was möchten Sie tun:</b></p>

<form wicket:id="fa">
<select wicket:id="ddc1">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>
<br>
<form wicket:id="fb">
<div>Die in der Datenbank vorhandenen Tabellen:</div>
<select wicket:id="tables">
<option></option>
</select>
<input type="submit" value="Optionen anzeigen"/>
</form>
<br>
<form wicket:id="fc">
<select wicket:id="options">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>

<wicket:child><wicket:extend>

<div wicket:id="infoText"></div>
<table>
<tr>
<th wicket:id="heading">
</th>
</tr>
<tr wicket:id="row">
<td wicket:id="cell">
</td>
</tr>
</table>
</wicket:extend></wicket:child>

</body>
</html>, index = 40, current = '<th wicket:id="heading">' (line 6, column 7)]

Root cause:

org.apache.wicket.markup.MarkupException: Unable to find component with id 'heading' in [MarkupContainer [Component id = _extend3]]. This means that you declared wicket:id=heading in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/C:/workspace/MyApp/context/WEB-INF/classes/myapp/dbtest/ListTabelle.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/postage.css">
<title>Datenbank-Designer</title>

</head>
<body>
<div wicket:id="feedback"></div>
<p>Willkommen beim DB-Designer 1.0! (c) by dg</p>
<p><b>Was möchten Sie tun:</b></p>

<form wicket:id="fa">
<select wicket:id="ddc1">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>
<br>
<form wicket:id="fb">
<div>Die in der Datenbank vorhandenen Tabellen:</div>
<select wicket:id="tables">
<option></option>
</select>
<input type="submit" value="Optionen anzeigen"/>
</form>
<br>
<form wicket:id="fc">
<select wicket:id="options">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>

<wicket:child><wicket:extend>

<div wicket:id="infoText"></div>
<table>
<tr>
<th wicket:id="heading">
</th>
</tr>
<tr wicket:id="row">
<td wicket:id="cell">
</td>
</tr>
</table>
</wicket:extend></wicket:child>

</body>
</html>, index = 40, current = '<th wicket:id="heading">' (line 6, column 7)]
at org.apache.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java:464)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1344)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1476)
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1401)
at org.apache.wicket.Component.renderComponent(Component.java:2480)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:223)
at org.apache.wicket.markup.resolver.MarkupInheritanceResolver.resolve(MarkupInheritanceResolver.java:66)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1324)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1476)
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1401)
at org.apache.wicket.Component.renderComponent(Component.java:2480)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:223)
at org.apache.wicket.markup.resolver.MarkupInheritanceResolver.resolve(MarkupInheritanceResolver.java:73)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1324)
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1427)
at org.apache.wicket.Page.onRender(Page.java:1470)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.Page.renderPage(Page.java:904)
at org.apache.wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:163)
at org.apache.wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:58)
at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:104)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1181)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1252)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:355)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:200)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)



-----Ursprüngliche Nachricht-----
Von: Martin Makundi [mailto:martin.makundi@koodaripalvelut.com] 
Gesendet: Montag, 25. Mai 2009 11:22
An: users@wicket.apache.org
Betreff: Re: MarkupException, BUT WHY???

What's the exception message?

2009/5/25 Dorothée Giernoth <Do...@kds-kg.de>:
> Hey all,
>
> I am quite new to Wicket, but I am trying some stuff to see how it works. Right now I am trying my best to build a little database-designer, but I get a MarkupException, but I dunno why. I am using MarkupInheritance ...
> My Code doesn't look very tidy, but I am still brave enough to post it. Hope someone sees where it fails. Thank you in advance!
>
> My first class-file, where it calls the second class-file, that includes the code, that will be loaded into the original html-file:
> -------------------------------------------------------------------------
> // DBDesigner.java:
> protected void onSubmit(){
>        String o = ( String ) drop3.getObject();
>        if( o.equals( "Datensaetze nur anzeigen" )){
>                try{
>                        String tab = tableList.get( tabelle );
>                        /* RESPONSEPAGE CALLED HERE!!!!*/
>                        ListTabelle listing = new ListTabelle( tab );
>                        setResponsePage( listing );
>                }
>                catch(Exception e){
>                        System.out.println( "TIENES UNA PROBLEMA: " + e );
>                }
>        }
> }
> --------------------------------------------------------------------------
>
>
> It calls ListTabelle.java where I load data from a database according to the choice of the user (the user chooses a table to collect to data from). I build up a RepeatingView that holds the data.
> I tried to just print the data in a label for shit and giggles and it worked, but something doesn't work with my RepeatingView (or with all the other Components I tried ...). I am missing something and tried for days now to figure out where my brain fails ... I just can't see it.
> Here is the code from ListTabelle.java (at least, what could be interesting):
> --------------------------------------------------------------------------
> package ...;
> import ...;
>
>
> public class ListTabelle extends DBDesigner implements Serializable{
>
>        // VARIABLES ...
>
>  /**
>   * Constructor
>   * @param conMe
>   * @param tab
>   */
>  public ListTabelle( String tab ){
>        this.tab = tab;
>
>        try {
>
>                /*
>                 *  CONNECTION TO DB:
>                 */
>                ...
>
>              try{
>                        showData();
>
>                        int sizeH = tabellenHeader.size();
>                        int sizeC = list.size();
>
>                        RepeatingView heading = new RepeatingView( "heading" );
>                        for( int i = 0; i <= sizeH; i++ ){
>                          heading.add( new Label( heading.newChildId(),
>                                                           tabellenHeader.get( i ) ) );
>                        }
>                        add( heading );
>                        RepeatingView row = new RepeatingView( "row" );
>                        add( row );
>
>                        for( int j = 0; j <= sizeC; j++ ){
>                          WebMarkupContainer r = new WebMarkupContainer(
>                                                                        row.newChildId() );
>                          RepeatingView cell = new RepeatingView( "cell" );
>                          row.add(r);
>                          r.add(cell);
>                          cell.add( new Label( cell.newChildId(),
>                                                        list.get( j ) ) )                                                 for( int d = 0; d <= sizeC; d++ ){
>                             cell.add( new Label( cell.newChildId(),
>                                                          list.get( j )  ) );
>                          }
>                        }
>
>
>
>                        /*
>                         * close the database
>                         */
>                        conMe.close();
>                    }
>                    catch( Exception e ){
>                        e.printStackTrace();
>                    }
>        }
>
>
>        /**
>         * Bastelt die Ausgabe-Liste aus der Datenbank zusammen.
>         */
>        private void showData(){
>
>                add( new Label( "infoText", "Ihre Daten werden angezeigt!" ) );
>
>                list = new ArrayList<String>();
>                tabellenHeader = new ArrayList<String>();
>                try {
>                        Statement cs = conMe.createStatement();
>                        // Tabellen-Header abfragen:
>                        ResultSet header = cs.executeQuery(
>                                                "SHOW COLUMNS FROM " + tab + ";" );
>                        anzahlSpalten = 0;
>                        while( header.next() ){
>                        anzahlSpalten++;
>                        tabellenHeader.add( inhalt );
>                        list.add( inhalt );
>                }
>
>            // Tabellen-Inhalt:
>            ResultSet tcontent = cs.executeQuery(
>                                                "SELECT * FROM " + tab + ";" );
>            // tcontent.next() - ist immer die neue Zeile, die dann
>            // spaltenweise ausgelesen werden kann.
>            while( tcontent.next() ){
>                for( int i = 0; i < anzahlSpalten; i++ ){
>                        list.add( tcontent.getString(
>                                                        tabellenHeader.get(i)));
>                }
>            }
>
>            System.out.println("Die ausgelesenen Daten: \n" + test);
>
>
>        }
>        catch( SQLException e ){
>                System.out.println( "Fehler SQL-Befehl: " + e );
>        }
>        }
> }
> --------------------------------------------------------------------------
>
>
> I put <wicket:child></wicket:child> into my DBDesigner.html-File and my ListTabelle.html looks like this:
> --------------------------------------------------------------------------
> <wicket:extend>
>        <div wicket:id="infoText"></div>
>        <table>
>                <tr>
>                        <th wicket:id="heading">
>                        </th>
>                </tr>
>                <tr wicket:id="row">
>                        <td wicket:id="cell">
>                        </td>
>                </tr>
>        </table>
> </wicket:extend>
> --------------------------------------------------------------------------
>
> I know this is a lot to read right now, but please bear with me ... I am just a baby-wicket-nerd and I am really desperate! I bet it is just a simple little thing, like - I dunno - a quotation mark ...
> I hope someone can help me.
> Thnx in advance again :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


AW: MarkupException, BUT WHY???

Posted by Dorothée Giernoth <Do...@kds-kg.de>.
Oh yeah, that might be helpful:
Here is the exception message:

WicketMessage: Unable to find component with id 'heading' in [MarkupContainer [Component id = _extend3]]. This means that you declared wicket:id=heading in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/C:/workspace/MyApp/context/WEB-INF/classes/myapp/dbtest/ListTabelle.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/postage.css">
<title>Datenbank-Designer</title>

</head>
<body>
<div wicket:id="feedback"></div>
<p>Willkommen beim DB-Designer 1.0! (c) by dg</p>
<p><b>Was möchten Sie tun:</b></p>

<form wicket:id="fa">
<select wicket:id="ddc1">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>
<br>
<form wicket:id="fb">
<div>Die in der Datenbank vorhandenen Tabellen:</div>
<select wicket:id="tables">
<option></option>
</select>
<input type="submit" value="Optionen anzeigen"/>
</form>
<br>
<form wicket:id="fc">
<select wicket:id="options">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>

<wicket:child><wicket:extend>

<div wicket:id="infoText"></div>
<table>
<tr>
<th wicket:id="heading">
</th>
</tr>
<tr wicket:id="row">
<td wicket:id="cell">
</td>
</tr>
</table>
</wicket:extend></wicket:child>

</body>
</html>, index = 40, current = '<th wicket:id="heading">' (line 6, column 7)]

Root cause:

org.apache.wicket.markup.MarkupException: Unable to find component with id 'heading' in [MarkupContainer [Component id = _extend3]]. This means that you declared wicket:id=heading in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/C:/workspace/MyApp/context/WEB-INF/classes/myapp/dbtest/ListTabelle.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/postage.css">
<title>Datenbank-Designer</title>

</head>
<body>
<div wicket:id="feedback"></div>
<p>Willkommen beim DB-Designer 1.0! (c) by dg</p>
<p><b>Was möchten Sie tun:</b></p>

<form wicket:id="fa">
<select wicket:id="ddc1">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>
<br>
<form wicket:id="fb">
<div>Die in der Datenbank vorhandenen Tabellen:</div>
<select wicket:id="tables">
<option></option>
</select>
<input type="submit" value="Optionen anzeigen"/>
</form>
<br>
<form wicket:id="fc">
<select wicket:id="options">
<option></option>
</select>
<input type="submit" value="Ok"/>
</form>

<wicket:child><wicket:extend>

<div wicket:id="infoText"></div>
<table>
<tr>
<th wicket:id="heading">
</th>
</tr>
<tr wicket:id="row">
<td wicket:id="cell">
</td>
</tr>
</table>
</wicket:extend></wicket:child>

</body>
</html>, index = 40, current = '<th wicket:id="heading">' (line 6, column 7)]
at org.apache.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java:464)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1344)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1476)
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1401)
at org.apache.wicket.Component.renderComponent(Component.java:2480)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:223)
at org.apache.wicket.markup.resolver.MarkupInheritanceResolver.resolve(MarkupInheritanceResolver.java:66)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1324)
at org.apache.wicket.MarkupContainer.renderComponentTagBody(MarkupContainer.java:1476)
at org.apache.wicket.MarkupContainer.onComponentTagBody(MarkupContainer.java:1401)
at org.apache.wicket.Component.renderComponent(Component.java:2480)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:223)
at org.apache.wicket.markup.resolver.MarkupInheritanceResolver.resolve(MarkupInheritanceResolver.java:73)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1324)
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1427)
at org.apache.wicket.Page.onRender(Page.java:1470)
at org.apache.wicket.Component.render(Component.java:2317)
at org.apache.wicket.Page.renderPage(Page.java:904)
at org.apache.wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:163)
at org.apache.wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:58)
at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:104)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1181)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1252)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1353)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:355)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:200)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)



-----Ursprüngliche Nachricht-----
Von: Martin Makundi [mailto:martin.makundi@koodaripalvelut.com] 
Gesendet: Montag, 25. Mai 2009 11:22
An: users@wicket.apache.org
Betreff: Re: MarkupException, BUT WHY???

What's the exception message?

2009/5/25 Dorothée Giernoth <Do...@kds-kg.de>:
> Hey all,
>
> I am quite new to Wicket, but I am trying some stuff to see how it works. Right now I am trying my best to build a little database-designer, but I get a MarkupException, but I dunno why. I am using MarkupInheritance ...
> My Code doesn't look very tidy, but I am still brave enough to post it. Hope someone sees where it fails. Thank you in advance!
>
> My first class-file, where it calls the second class-file, that includes the code, that will be loaded into the original html-file:
> -------------------------------------------------------------------------
> // DBDesigner.java:
> protected void onSubmit(){
>        String o = ( String ) drop3.getObject();
>        if( o.equals( "Datensaetze nur anzeigen" )){
>                try{
>                        String tab = tableList.get( tabelle );
>                        /* RESPONSEPAGE CALLED HERE!!!!*/
>                        ListTabelle listing = new ListTabelle( tab );
>                        setResponsePage( listing );
>                }
>                catch(Exception e){
>                        System.out.println( "TIENES UNA PROBLEMA: " + e );
>                }
>        }
> }
> --------------------------------------------------------------------------
>
>
> It calls ListTabelle.java where I load data from a database according to the choice of the user (the user chooses a table to collect to data from). I build up a RepeatingView that holds the data.
> I tried to just print the data in a label for shit and giggles and it worked, but something doesn't work with my RepeatingView (or with all the other Components I tried ...). I am missing something and tried for days now to figure out where my brain fails ... I just can't see it.
> Here is the code from ListTabelle.java (at least, what could be interesting):
> --------------------------------------------------------------------------
> package ...;
> import ...;
>
>
> public class ListTabelle extends DBDesigner implements Serializable{
>
>        // VARIABLES ...
>
>  /**
>   * Constructor
>   * @param conMe
>   * @param tab
>   */
>  public ListTabelle( String tab ){
>        this.tab = tab;
>
>        try {
>
>                /*
>                 *  CONNECTION TO DB:
>                 */
>                ...
>
>              try{
>                        showData();
>
>                        int sizeH = tabellenHeader.size();
>                        int sizeC = list.size();
>
>                        RepeatingView heading = new RepeatingView( "heading" );
>                        for( int i = 0; i <= sizeH; i++ ){
>                          heading.add( new Label( heading.newChildId(),
>                                                           tabellenHeader.get( i ) ) );
>                        }
>                        add( heading );
>                        RepeatingView row = new RepeatingView( "row" );
>                        add( row );
>
>                        for( int j = 0; j <= sizeC; j++ ){
>                          WebMarkupContainer r = new WebMarkupContainer(
>                                                                        row.newChildId() );
>                          RepeatingView cell = new RepeatingView( "cell" );
>                          row.add(r);
>                          r.add(cell);
>                          cell.add( new Label( cell.newChildId(),
>                                                        list.get( j ) ) )                                                 for( int d = 0; d <= sizeC; d++ ){
>                             cell.add( new Label( cell.newChildId(),
>                                                          list.get( j )  ) );
>                          }
>                        }
>
>
>
>                        /*
>                         * close the database
>                         */
>                        conMe.close();
>                    }
>                    catch( Exception e ){
>                        e.printStackTrace();
>                    }
>        }
>
>
>        /**
>         * Bastelt die Ausgabe-Liste aus der Datenbank zusammen.
>         */
>        private void showData(){
>
>                add( new Label( "infoText", "Ihre Daten werden angezeigt!" ) );
>
>                list = new ArrayList<String>();
>                tabellenHeader = new ArrayList<String>();
>                try {
>                        Statement cs = conMe.createStatement();
>                        // Tabellen-Header abfragen:
>                        ResultSet header = cs.executeQuery(
>                                                "SHOW COLUMNS FROM " + tab + ";" );
>                        anzahlSpalten = 0;
>                        while( header.next() ){
>                        anzahlSpalten++;
>                        tabellenHeader.add( inhalt );
>                        list.add( inhalt );
>                }
>
>            // Tabellen-Inhalt:
>            ResultSet tcontent = cs.executeQuery(
>                                                "SELECT * FROM " + tab + ";" );
>            // tcontent.next() - ist immer die neue Zeile, die dann
>            // spaltenweise ausgelesen werden kann.
>            while( tcontent.next() ){
>                for( int i = 0; i < anzahlSpalten; i++ ){
>                        list.add( tcontent.getString(
>                                                        tabellenHeader.get(i)));
>                }
>            }
>
>            System.out.println("Die ausgelesenen Daten: \n" + test);
>
>
>        }
>        catch( SQLException e ){
>                System.out.println( "Fehler SQL-Befehl: " + e );
>        }
>        }
> }
> --------------------------------------------------------------------------
>
>
> I put <wicket:child></wicket:child> into my DBDesigner.html-File and my ListTabelle.html looks like this:
> --------------------------------------------------------------------------
> <wicket:extend>
>        <div wicket:id="infoText"></div>
>        <table>
>                <tr>
>                        <th wicket:id="heading">
>                        </th>
>                </tr>
>                <tr wicket:id="row">
>                        <td wicket:id="cell">
>                        </td>
>                </tr>
>        </table>
> </wicket:extend>
> --------------------------------------------------------------------------
>
> I know this is a lot to read right now, but please bear with me ... I am just a baby-wicket-nerd and I am really desperate! I bet it is just a simple little thing, like - I dunno - a quotation mark ...
> I hope someone can help me.
> Thnx in advance again :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: MarkupException, BUT WHY???

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
What's the exception message?

2009/5/25 Dorothée Giernoth <Do...@kds-kg.de>:
> Hey all,
>
> I am quite new to Wicket, but I am trying some stuff to see how it works. Right now I am trying my best to build a little database-designer, but I get a MarkupException, but I dunno why. I am using MarkupInheritance ...
> My Code doesn't look very tidy, but I am still brave enough to post it. Hope someone sees where it fails. Thank you in advance!
>
> My first class-file, where it calls the second class-file, that includes the code, that will be loaded into the original html-file:
> -------------------------------------------------------------------------
> // DBDesigner.java:
> protected void onSubmit(){
>        String o = ( String ) drop3.getObject();
>        if( o.equals( "Datensaetze nur anzeigen" )){
>                try{
>                        String tab = tableList.get( tabelle );
>                        /* RESPONSEPAGE CALLED HERE!!!!*/
>                        ListTabelle listing = new ListTabelle( tab );
>                        setResponsePage( listing );
>                }
>                catch(Exception e){
>                        System.out.println( "TIENES UNA PROBLEMA: " + e );
>                }
>        }
> }
> --------------------------------------------------------------------------
>
>
> It calls ListTabelle.java where I load data from a database according to the choice of the user (the user chooses a table to collect to data from). I build up a RepeatingView that holds the data.
> I tried to just print the data in a label for shit and giggles and it worked, but something doesn't work with my RepeatingView (or with all the other Components I tried ...). I am missing something and tried for days now to figure out where my brain fails ... I just can't see it.
> Here is the code from ListTabelle.java (at least, what could be interesting):
> --------------------------------------------------------------------------
> package ...;
> import ...;
>
>
> public class ListTabelle extends DBDesigner implements Serializable{
>
>        // VARIABLES ...
>
>  /**
>   * Constructor
>   * @param conMe
>   * @param tab
>   */
>  public ListTabelle( String tab ){
>        this.tab = tab;
>
>        try {
>
>                /*
>                 *  CONNECTION TO DB:
>                 */
>                ...
>
>              try{
>                        showData();
>
>                        int sizeH = tabellenHeader.size();
>                        int sizeC = list.size();
>
>                        RepeatingView heading = new RepeatingView( "heading" );
>                        for( int i = 0; i <= sizeH; i++ ){
>                          heading.add( new Label( heading.newChildId(),
>                                                           tabellenHeader.get( i ) ) );
>                        }
>                        add( heading );
>                        RepeatingView row = new RepeatingView( "row" );
>                        add( row );
>
>                        for( int j = 0; j <= sizeC; j++ ){
>                          WebMarkupContainer r = new WebMarkupContainer(
>                                                                        row.newChildId() );
>                          RepeatingView cell = new RepeatingView( "cell" );
>                          row.add(r);
>                          r.add(cell);
>                          cell.add( new Label( cell.newChildId(),
>                                                        list.get( j ) ) )                                                 for( int d = 0; d <= sizeC; d++ ){
>                             cell.add( new Label( cell.newChildId(),
>                                                          list.get( j )  ) );
>                          }
>                        }
>
>
>
>                        /*
>                         * close the database
>                         */
>                        conMe.close();
>                    }
>                    catch( Exception e ){
>                        e.printStackTrace();
>                    }
>        }
>
>
>        /**
>         * Bastelt die Ausgabe-Liste aus der Datenbank zusammen.
>         */
>        private void showData(){
>
>                add( new Label( "infoText", "Ihre Daten werden angezeigt!" ) );
>
>                list = new ArrayList<String>();
>                tabellenHeader = new ArrayList<String>();
>                try {
>                        Statement cs = conMe.createStatement();
>                        // Tabellen-Header abfragen:
>                        ResultSet header = cs.executeQuery(
>                                                "SHOW COLUMNS FROM " + tab + ";" );
>                        anzahlSpalten = 0;
>                        while( header.next() ){
>                        anzahlSpalten++;
>                        tabellenHeader.add( inhalt );
>                        list.add( inhalt );
>                }
>
>            // Tabellen-Inhalt:
>            ResultSet tcontent = cs.executeQuery(
>                                                "SELECT * FROM " + tab + ";" );
>            // tcontent.next() - ist immer die neue Zeile, die dann
>            // spaltenweise ausgelesen werden kann.
>            while( tcontent.next() ){
>                for( int i = 0; i < anzahlSpalten; i++ ){
>                        list.add( tcontent.getString(
>                                                        tabellenHeader.get(i)));
>                }
>            }
>
>            System.out.println("Die ausgelesenen Daten: \n" + test);
>
>
>        }
>        catch( SQLException e ){
>                System.out.println( "Fehler SQL-Befehl: " + e );
>        }
>        }
> }
> --------------------------------------------------------------------------
>
>
> I put <wicket:child></wicket:child> into my DBDesigner.html-File and my ListTabelle.html looks like this:
> --------------------------------------------------------------------------
> <wicket:extend>
>        <div wicket:id="infoText"></div>
>        <table>
>                <tr>
>                        <th wicket:id="heading">
>                        </th>
>                </tr>
>                <tr wicket:id="row">
>                        <td wicket:id="cell">
>                        </td>
>                </tr>
>        </table>
> </wicket:extend>
> --------------------------------------------------------------------------
>
> I know this is a lot to read right now, but please bear with me ... I am just a baby-wicket-nerd and I am really desperate! I bet it is just a simple little thing, like - I dunno - a quotation mark ...
> I hope someone can help me.
> Thnx in advance again :)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


MarkupException, BUT WHY???

Posted by Dorothée Giernoth <Do...@kds-kg.de>.
Hey all,

I am quite new to Wicket, but I am trying some stuff to see how it works. Right now I am trying my best to build a little database-designer, but I get a MarkupException, but I dunno why. I am using MarkupInheritance ...
My Code doesn't look very tidy, but I am still brave enough to post it. Hope someone sees where it fails. Thank you in advance!

My first class-file, where it calls the second class-file, that includes the code, that will be loaded into the original html-file:
-------------------------------------------------------------------------
// DBDesigner.java:
protected void onSubmit(){
	String o = ( String ) drop3.getObject();
	if( o.equals( "Datensaetze nur anzeigen" )){
		try{
			String tab = tableList.get( tabelle );
			/* RESPONSEPAGE CALLED HERE!!!!*/
			ListTabelle listing = new ListTabelle( tab );
			setResponsePage( listing );
		}
		catch(Exception e){
			System.out.println( "TIENES UNA PROBLEMA: " + e );
		}
	}
}
--------------------------------------------------------------------------


It calls ListTabelle.java where I load data from a database according to the choice of the user (the user chooses a table to collect to data from). I build up a RepeatingView that holds the data.
I tried to just print the data in a label for shit and giggles and it worked, but something doesn't work with my RepeatingView (or with all the other Components I tried ...). I am missing something and tried for days now to figure out where my brain fails ... I just can't see it.
Here is the code from ListTabelle.java (at least, what could be interesting):
--------------------------------------------------------------------------
package ...;
import ...;


public class ListTabelle extends DBDesigner implements Serializable{
	
	// VARIABLES ... 
	
  /**
   * Constructor
   * @param conMe
   * @param tab
   */
  public ListTabelle( String tab ){
	this.tab = tab;
	
	try {
		    	
		/*
		 *  CONNECTION TO DB:
		 */
		...
			        
	      try{
			showData();
					
			int sizeH = tabellenHeader.size();
			int sizeC = list.size();
					
			RepeatingView heading = new RepeatingView( "heading" );
			for( int i = 0; i <= sizeH; i++ ){
			  heading.add( new Label( heading.newChildId(),
							   tabellenHeader.get( i ) ) );
			}
			add( heading );
			RepeatingView row = new RepeatingView( "row" );
			add( row );
					
			for( int j = 0; j <= sizeC; j++ ){
			  WebMarkupContainer r = new WebMarkupContainer( 
									row.newChildId() );
   			  RepeatingView cell = new RepeatingView( "cell" );
			  row.add(r);
			  r.add(cell);
			  cell.add( new Label( cell.newChildId(), 
							list.get( j ) ) )					   	  for( int d = 0; d <= sizeC; d++ ){
			     cell.add( new Label( cell.newChildId(), 
							  list.get( j )  ) );
			  }
			}

			

		        /* 
		         * close the database 
		         */
		        conMe.close();
		    } 
		    catch( Exception e ){
			e.printStackTrace();
		    }
	}
	
	
	/**
	 * Bastelt die Ausgabe-Liste aus der Datenbank zusammen.
	 */
	private void showData(){

		add( new Label( "infoText", "Ihre Daten werden angezeigt!" ) );
		
		list = new ArrayList<String>();
		tabellenHeader = new ArrayList<String>();
		try {
			Statement cs = conMe.createStatement();
			// Tabellen-Header abfragen:
			ResultSet header = cs.executeQuery( 
						"SHOW COLUMNS FROM " + tab + ";" );
			anzahlSpalten = 0;
			while( header.next() ){
            		anzahlSpalten++;
            		tabellenHeader.add( inhalt );
            		list.add( inhalt );
            	}
			
            // Tabellen-Inhalt:
            ResultSet tcontent = cs.executeQuery( 
						"SELECT * FROM " + tab + ";" );
            // tcontent.next() - ist immer die neue Zeile, die dann 
            // spaltenweise ausgelesen werden kann.
            while( tcontent.next() ){
            	for( int i = 0; i < anzahlSpalten; i++ ){
            		list.add( tcontent.getString( 
							tabellenHeader.get(i)));
            	}
            }
            	
            System.out.println("Die ausgelesenen Daten: \n" + test);
            
            
        } 
        catch( SQLException e ){
        	System.out.println( "Fehler SQL-Befehl: " + e );
        }
	}
}
--------------------------------------------------------------------------


I put <wicket:child></wicket:child> into my DBDesigner.html-File and my ListTabelle.html looks like this:
--------------------------------------------------------------------------
<wicket:extend>
	<div wicket:id="infoText"></div> 
	<table>
		<tr>
   			<th wicket:id="heading">
  			</th>
		</tr>
		<tr wicket:id="row">
  			<td wicket:id="cell">
  			</td>
		</tr> 
	</table>
</wicket:extend>
--------------------------------------------------------------------------

I know this is a lot to read right now, but please bear with me ... I am just a baby-wicket-nerd and I am really desperate! I bet it is just a simple little thing, like - I dunno - a quotation mark ... 
I hope someone can help me.
Thnx in advance again :)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AW: How to validate unique constraint?

Posted by Vladimir K <ko...@gmail.com>.
Hibernate Validator is useful for bean validations but it has nothing to do
with unique constraint for which you should consult database unless you
cache all the instances.

I would like to provide user with an early warning that the data it fills in
is not unique but I haven't found solution out of the box that uses entity
annotations, especially UniqueContraint.


Dorothée Giernoth wrote:
> 
> 
> 
> I would find this very useful! So a contribution to wicket-stuff would be
> awesome. Thnx.
> 
> - dg
>  
> -----Ursprüngliche Nachricht-----
> Von: Clint Popetz [mailto:clint@42lines.net] 
> Gesendet: Dienstag, 19. Mai 2009 13:49
> An: users@wicket.apache.org
> Betreff: Re: How to validate unique constraint?
> 
> It's relatively straightforward to use the hibernate validator api to
> apply JPA constraints:
> 
> import org.hibernate.validator.*;
> InvalidValue[] invalidValues = new
> ClassValidator(MyModel.class).getInvalidValues(instanceOfMyModel);
> 
> This can also be done per-property; see the javadocs.
> 
> I've done this locally; if folks would find it useful I'll contribute
> it to wicketstuff.
> 
> -Clint
> 
> On Tue, May 19, 2009 at 2:15 AM, Christian Helmbold
> <ch...@yahoo.de> wrote:
>>
>> How can I validate a unique constraint with Wicket? Because only the
>> value of an input field is passed to onValidate(IValidatable
>> validatable), there is no chance to check if this value belongs to a
>> specific object to update or if it would violate a unique constraint when
>> creating a new object. onValidate would need another paremeter for the
>> related object.
>>
>> I see two possibilities:
>>
>> a) Use a form validator and get the related model object from the form.
>>
>> b) Pass the related object to the constructor of the Validator. I'm not
>> sure, if the validator would be recreated any time the model object
>> changes.
>>
>> I would prefer a validator tied to the field and not to the form, because
>> that would be more intuitive.
>>
>> Another idea is to use existing JPA annotations. @Column(unique=true) is
>> already there but not used for validation (outside the database). Perhaps
>> there is a way to use this annotation. I really like the domain level
>> validation of Grails:
>> http://grails.org/doc/1.1/guide/7.%20Validation.html
>>
>> How would you validate a unique constraint with wicket?
>>
>> Thanks in advance
>> Christian
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 
> 
> -- 
> Clint Popetz
> http://42lines.net
> Scalable Web Application Development
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-validate-unique-constraint--tp23610946p23629304.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to validate unique constraint?

Posted by Clint Popetz <cl...@42lines.net>.
I cleaned up my hibernate-validator/wicket integration code, and put
it along with an example in my public svn repository.  I describe the
integration and the example here:

http://42lines.net/content/integrating-hibernate-validator-and-wicket

If people care to leave feedback, please do.  In particular I'm
interested in whether it's worth contributing it to wicketstuff.

-Clint

2009/5/19 Dorothée Giernoth <Do...@kds-kg.de>:
>
>
> I would find this very useful! So a contribution to wicket-stuff would be awesome. Thnx.
>
> - dg
>
> -----Ursprüngliche Nachricht-----
> Von: Clint Popetz [mailto:clint@42lines.net]
> Gesendet: Dienstag, 19. Mai 2009 13:49
> An: users@wicket.apache.org
> Betreff: Re: How to validate unique constraint?
>
> It's relatively straightforward to use the hibernate validator api to
> apply JPA constraints:
>
> import org.hibernate.validator.*;
> InvalidValue[] invalidValues = new
> ClassValidator(MyModel.class).getInvalidValues(instanceOfMyModel);
>
> This can also be done per-property; see the javadocs.
>
> I've done this locally; if folks would find it useful I'll contribute
> it to wicketstuff.
>
> -Clint
>
> On Tue, May 19, 2009 at 2:15 AM, Christian Helmbold
> <ch...@yahoo.de> wrote:
>>
>> How can I validate a unique constraint with Wicket? Because only the value of an input field is passed to onValidate(IValidatable validatable), there is no chance to check if this value belongs to a specific object to update or if it would violate a unique constraint when creating a new object. onValidate would need another paremeter for the related object.
>>
>> I see two possibilities:
>>
>> a) Use a form validator and get the related model object from the form.
>>
>> b) Pass the related object to the constructor of the Validator. I'm not sure, if the validator would be recreated any time the model object changes.
>>
>> I would prefer a validator tied to the field and not to the form, because that would be more intuitive.
>>
>> Another idea is to use existing JPA annotations. @Column(unique=true) is already there but not used for validation (outside the database). Perhaps there is a way to use this annotation. I really like the domain level validation of Grails: http://grails.org/doc/1.1/guide/7.%20Validation.html
>>
>> How would you validate a unique constraint with wicket?
>>
>> Thanks in advance
>> Christian
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
>
> --
> Clint Popetz
> http://42lines.net
> Scalable Web Application Development
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Clint Popetz
http://42lines.net
Scalable Web Application Development

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


AW: How to validate unique constraint?

Posted by Dorothée Giernoth <Do...@kds-kg.de>.

I would find this very useful! So a contribution to wicket-stuff would be awesome. Thnx.

- dg
 
-----Ursprüngliche Nachricht-----
Von: Clint Popetz [mailto:clint@42lines.net] 
Gesendet: Dienstag, 19. Mai 2009 13:49
An: users@wicket.apache.org
Betreff: Re: How to validate unique constraint?

It's relatively straightforward to use the hibernate validator api to
apply JPA constraints:

import org.hibernate.validator.*;
InvalidValue[] invalidValues = new
ClassValidator(MyModel.class).getInvalidValues(instanceOfMyModel);

This can also be done per-property; see the javadocs.

I've done this locally; if folks would find it useful I'll contribute
it to wicketstuff.

-Clint

On Tue, May 19, 2009 at 2:15 AM, Christian Helmbold
<ch...@yahoo.de> wrote:
>
> How can I validate a unique constraint with Wicket? Because only the value of an input field is passed to onValidate(IValidatable validatable), there is no chance to check if this value belongs to a specific object to update or if it would violate a unique constraint when creating a new object. onValidate would need another paremeter for the related object.
>
> I see two possibilities:
>
> a) Use a form validator and get the related model object from the form.
>
> b) Pass the related object to the constructor of the Validator. I'm not sure, if the validator would be recreated any time the model object changes.
>
> I would prefer a validator tied to the field and not to the form, because that would be more intuitive.
>
> Another idea is to use existing JPA annotations. @Column(unique=true) is already there but not used for validation (outside the database). Perhaps there is a way to use this annotation. I really like the domain level validation of Grails: http://grails.org/doc/1.1/guide/7.%20Validation.html
>
> How would you validate a unique constraint with wicket?
>
> Thanks in advance
> Christian
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Clint Popetz
http://42lines.net
Scalable Web Application Development

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to validate unique constraint?

Posted by Clint Popetz <cl...@42lines.net>.
It's relatively straightforward to use the hibernate validator api to
apply JPA constraints:

import org.hibernate.validator.*;
InvalidValue[] invalidValues = new
ClassValidator(MyModel.class).getInvalidValues(instanceOfMyModel);

This can also be done per-property; see the javadocs.

I've done this locally; if folks would find it useful I'll contribute
it to wicketstuff.

-Clint

On Tue, May 19, 2009 at 2:15 AM, Christian Helmbold
<ch...@yahoo.de> wrote:
>
> How can I validate a unique constraint with Wicket? Because only the value of an input field is passed to onValidate(IValidatable validatable), there is no chance to check if this value belongs to a specific object to update or if it would violate a unique constraint when creating a new object. onValidate would need another paremeter for the related object.
>
> I see two possibilities:
>
> a) Use a form validator and get the related model object from the form.
>
> b) Pass the related object to the constructor of the Validator. I'm not sure, if the validator would be recreated any time the model object changes.
>
> I would prefer a validator tied to the field and not to the form, because that would be more intuitive.
>
> Another idea is to use existing JPA annotations. @Column(unique=true) is already there but not used for validation (outside the database). Perhaps there is a way to use this annotation. I really like the domain level validation of Grails: http://grails.org/doc/1.1/guide/7.%20Validation.html
>
> How would you validate a unique constraint with wicket?
>
> Thanks in advance
> Christian
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Clint Popetz
http://42lines.net
Scalable Web Application Development

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: How to validate unique constraint?

Posted by Igor Vaynberg <ig...@gmail.com>.
Pass the id of the entity being edited into the validator and check
the database in validate()

Alternatively catch the exception in the form's onsubmit and call
error on the right component.

-igor

On Tuesday, May 19, 2009, Christian Helmbold
<ch...@yahoo.de> wrote:
>
> How can I validate a unique constraint with Wicket? Because only the value of an input field is passed to onValidate(IValidatable validatable), there is no chance to check if this value belongs to a specific object to update or if it would violate a unique constraint when creating a new object. onValidate would need another paremeter for the related object.
>
> I see two possibilities:
>
> a) Use a form validator and get the related model object from the form.
>
> b) Pass the related object to the constructor of the Validator. I'm not sure, if the validator would be recreated any time the model object changes.
>
> I would prefer a validator tied to the field and not to the form, because that would be more intuitive.
>
> Another idea is to use existing JPA annotations. @Column(unique=true) is already there but not used for validation (outside the database). Perhaps there is a way to use this annotation. I really like the domain level validation of Grails: http://grails.org/doc/1.1/guide/7.%20Validation.html
>
> How would you validate a unique constraint with wicket?
>
> Thanks in advance
> Christian
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org