cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antonio Gallardo" <agalla...@agsoftware.dnsalias.com>
Subject Re: how to generate random numbers or strings?
Date Fri, 07 Mar 2003 13:09:53 GMT
Hello!

I meet this problem some months ago. I made a solution using XSP. I think
you can easily enhance this piece of code:

<xsp:logic>
	String key = <xsp-request:get-parameter name="table_id" default=""/>;
	while (key.equals("")) {
		Random aleatorio = new Random();
		int new_key = aleatorio.nextInt(Integer.MAX_VALUE) + 1;
		llave = String.valueOf(new_key);
		/* Check into database if the key exist into the table */
		<esql:execute-query>
			<esql:query>
				SELECT table_id FROM table WHERE table_id=<esql:parameter
type="int"><xsp:expr>new_key</xsp:expr></esql:parameter>
			</esql:query>
			<esql:results>
				<esql:row-results>
					key = "";
				</esql:row-results>
			</esql:results>
		</esql:execute-query>
	}
</xsp:logic>
<parameter name="table_id"><xsp:attribute
name="value"><xsp:expr>key</xsp:expr></xsp:attribute></parameter>

best regards,

Antonio Gallardo



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


Mime
View raw message