Click to See Complete Forum and Search --> : organizing table row in jsp


Rxyz
03-07-2006, 01:15 PM
<tr>
<td>
<fmt:message key="lbl.balance" bundle="${bundle}"/><fmt:message key="colon" bundle="${bundle}"/>
</td>
<td><fmt:message key="dollar" bundle="${bundle}"/></td>
<td>
<html:text name="Form1" property="balance" errorStyleClass="errormessage"/>
<span class="required">*</span>
</td>
<td><span class="errors"><html:errors property="balance"/></span></td>
</tr>

I am creating the JSP's. In it I am trying to place a label, $ sign followed by a textfield, and sometimes percentage symbol beside it, follwed by a required symbol(*) followed by a error message if any.

My question is I am trying to put all these is different columns in table row.

Is there a better way to do the same. when errors are there as it's placed in different column the row size are getting increased. visually I see each row is twice the row before when error message is displayed.

I tried to put use span to place error message after the required symbol in it's column. when did this the error message is displayed in the next line itself.

What is the better way to do this?

Thanks.

ray326
03-07-2006, 10:34 PM
Is that tabular data? If not then start by removing the table. If it's just a form then consider using this pattern.

<div><label for="id">label</label><input id="id"...></div>

or the simpler but less stylable

<label><input ...></label>

Rxyz
03-08-2006, 08:54 AM
thankyou for your response.


trying to create

Customer Name: Input field here (*) error message(if any)
Customer type: drop down box here (*) error message(if any)
Customer Address Input field here (*) error message(if any)

I tried to use div.

<div>
<fmt:message key="lbl.accttype" bundle="${bundle}"/><fmt:message key="colon" bundle="${bundle}"/>
<html:select name="Form1" property="acctTypeSelected" errorStyleClass="errormessage">
<html:options collection="acctTypeList" property="value" labelProperty="label"/>
</html:select>
<span class="required">*</span>
<span class="errors"><html:errors property="acctTypeSelected"/></span>
</div>

when error had to be displayed it is getting displayed at the bottom

i.e
Customer Type : drop down here(*)
error message here------------ want this in the above line itself.

also I see that using div
Customer Name: input field(*)
Customer Address: input field(*)

The input fields get displayed right beside the label. sometimes the labels could be large too. do I have to use span to make sure that input fields are on a line?

using table I don't have to worry about this.

how do I make sure the error message is on the same line when using div?

Thanks.

ray326
03-08-2006, 12:28 PM
Check the generated code to see if the custom tag is generating a paragraph for that error message.

Rxyz
03-08-2006, 12:51 PM
this is what I see when I do view source

<span class="errors" id="a"><UL><LI>Required</LI></UL></span>

is this what that's putting it in next line?

Thanks.

ray326
03-08-2006, 12:57 PM
Yep. Is that Struts? If so I highly recommend the Manning book Struts Recipes for best practices in that framework.

Rxyz
03-08-2006, 01:02 PM
I have no other alternative but to use the table and put error in one of the column and feel the pain of each row taking up the 2 row size when there are errors.

it should have returned a String instead of <UL> right!!

Then everything would have been fine.

Thanks Ray, for helping me with this.