• Post Reply Bookmark Topic Watch Topic
  • New Topic

TextBox having same name  RSS feed

 
pax smith
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I need to create some textboxes having same name and no of textbox also can be determined runtime.


can anybody has a solution


Thanks
 
Periakaruppan Thiagarajan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you will be knowing the no of text boxes to be generated at run time, you can make use of the tag <logic:iterate/> which is similar to for loop in Java.
 
pax smith
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI

my problem is like that I am iterating a hashmap and I need to display a texbox in the front of each row

My code is like that in action

private String seqNo[] ;
public String getSeqNo(int index) {
return seqNo[index];
}
public void setSeqNo(String seqNo , int index) {
this.seqNo[index] = seqNo;

JSP code

...code...
<logic-l:iterate id="itempro" name="hmitemProperties" indexId="ctr">
html:text property="seqNo[ctr]" name="addTemplateForm"/>

..code....

But it is not working. Can you please tell me where is the mistake
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you use a scriptlet, Struts will assume that the property name you specify is a literal. Try changing your html:text tag as follows:


<html:text property='<%="seqNo["+ctr+"]"%>' name="addTemplateForm"/>

Alternatively, if you're using the struts-el version of the tags, you could write:

<html-el:text property="seqNo[${ctr}]" />
 
pax smith
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Merrill

Thanks for taking interest.
I am using struts-el version. I have used <html:text property="seqNo['${ctr}']" /> but still it gives error.

Thanks & Regards
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get rid of the single quotes around ${ctr}.

If that still doesn't work, please be more specific than "doesn't work". Give us the error message you're getting and describe specifically what is going wrong.
 
pax smith
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi


I have tried <html:text property="seqNo[${ctr}]" name="addTemplateForm" /> But also it does not work. I specified it "doesnot work" because It shows just a blank Page. there is no other error in my JSP because if I omit this particular line then my JSP works fine.


Please tell me Is there any Way so that I can check what the actual error is? and Please help me to solve this problem



Thanks & Regards
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The next thing I'd do is verify that you have set up the struts-el tags properly.

Check that you have the following in your jsp:

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>

You must also have struts-el.jar and jstl.jar in your WEB-INF/lib directory.

If this is all correct, then I'd use the "view source" function of the browser to see what html has been rendered by Struts. you should see
<input type="text" name="seqNo[0]" />
<input type="text" name="seqNo[1]" /> ..etc.
 
pax smith
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks for taking interest and sorry I am taking your lot of time.
I am working on an application and all my configuration setting and placement of jstl.jar and struts.jar etc. are quite right beacuse on the same JSP I am using some other tags which are working quite well.

Second thing in that particular case JSP doesnot show proper output that because of some error in converting struts tag to HTML tags that's why when I see the code in view source it does not show the complete code. There is no entry of

<input type="text" name="seqNo[0]" />
<input type="text" name="seqNo[1]" />
Because struts code is not fully rendered in HTML.

Is there any other way to see the error

Thanks & Regards

Pankaj Jain
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!