<hrml:link> does not accept scriplets?

Hi,

I am not able to pass a scriplet as a parameter using <html:link> where the same is working in <a href>?

For eg,

<html:link href='#' onclick='doSubmit("doCreateEmpRecord",

"<%=empId%>")> create </html:link>

Not working where it is working for <a href> ?

What is the problem here... Pls. do provide an answer for this.

Thanks

--JavaCrazyLover--'>

[448 byte] By [AnanthJavaa] at [2007-11-15]
# 1

i think sometimes you can run into problems when you try to use it in javascript like that.

what happens if you try to make a normal link, like

<tml:link href='<%=whatever%>'> create </html:link>

i would start there and continuing making it more complex until you find the point it stops working.

note, you can instead of using an onclick event use something like ....href="javascript: functionName(whatever, whatever2)">

fool around with that and let me know what you get.

den2681a at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 2

With struts tags in particular, if you are going to make an attribute dynamic, make the whole attribute dynamic.

<html:link href='#' onclick='doSubmit("doCreateEmpRecord","<%=empId%>")'> create </html:link>

Try

<html:link href='#' onclick='<%= "doSubmit(\"doCreateEmpRecord\"," + empId " + ")" %>'> create </html:link>

- the whole "onclick" attribute becomes a runtime expression, rather than a mix of string and <%= expr %>

Cheers,

evnafets

evnafetsa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 3

Evn,

When i try to use this:-

<bean:define name='client' property='clientId' id="clientId"/>

<html:link href='#' onclick='<%= "doSubmitXXX(\"doDisplayEditClientPage\"," + clientId + ")" %>'> create </html:link>

Where

I'm getting the following error:-

clientSearch.jsp:211:46: No variable or field with this name could be found at this location.

<html:link href='#' onclick='<%= "doSubmit(\"doDisplayEditClientPage\"," + clientId + ")" %>'> create </html:link>

^^

clientSearch.jsp:211:46: Syntax error: expected , (found 'doDisplayEditClientPage' instead)

<html:link href='#' onclick='<%= "doSubmit(\"doDisplayEditClientPage\"," + clientId + ")" %>'> create </html:link>

^^

clientSearch.jsp:211:69: Syntax error: expected ) (found '<string literal>' instead)

<html:link href='#' onclick='<%= "doSubmit(\"doDisplayEditClientPage\"," + clientId + ")" %>'> create </html:link>

^-^

clientSearch.jsp:211:69: Illegal use of an expression as a statement.

<html:link href='#' onclick='<%= "doSubmit(\"doDisplayEditClientPage\"," + clientId + ")" %>'> create </html:link>

^-^

clientSearch.jsp:211:87: Syntax error: expected ; (found ')' instead)

<html:link href='#' onclick='<%= "doSubmit(\"doDisplayEditClientPage\"," + clientId + ")" %>'> create </html:link>

Can u please solve the problem. It looks ok.. But still i am getting the error.

Thanks,

--JavaCrazyLover--

AnanthJavaa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 4
Character 46 is were we have the \" character. Can't see anything basically wrong.Try using different quotes. ie instead of \", use ' in the onclick expression to see if that makes a difference maybe?What server are you using?
evnafetsa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 5

Evn,

You are really great...It is working after giving single quote for the action method. I am using weblogic 9.2. Thank u very much ...

I have one more ques. for u.

I have a search text box ,where i will key in the data

like "TigerWoods" where the data in the Database is like

"TIGerWooDs". So when i pass the name as a paremeter in the

DAO layer and send the parameter in a query to find the name. It is giving me no result since the name entered in the text box does not match with the data in the DB(with upper & lower case letters). Where the name is the same. where it should accept the name entered and give me the result like name found.

One thing is that i can't convert by name into uppercase or lowercase

letters in my application. Becos, the DB will have the name in any format (with both upper & lower case letters). How to solve this pbm. pls. do provide a soln. to this pbm. since this is quite urgent...

Thanks

--JavaCrazyLover--

AnanthJavaa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 6

>I am using weblogic 9.2.

Bingo. Weblogic has an issue with quotes like that sometimes. Something to do with their JSP parser.

Regarding the search, most databases don't have an equals ignore case comparision. What database are you using? The standard approach is to convert both the search value and the db column to one case or the other when comparing

String enteredSearchValue = request.getParameter("searchValue").toUpperCase();

select * from users where upper(username) = ?

evnafetsa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 7
Thanks Evn, I' m using Oracle 9i.
AnanthJavaa at 2007-7-12 > top of java,Enterprise & Remote Computing,Web Tier APIs...