You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by "anuradha.g" <ga...@prokarma.com> on 2007/07/24 16:12:38 UTC

Problem in retrieving the dynamic text field values

Hi,
 I'm a newbie in wicket. Can any one please help me in solving my problem

 In HTML page, I'm adding wicket textfields to the table dynamically using
java script (on every click of ' 'Add Row' button, a new row of wicket text
fields is added to the table dynamiccaly) . I'm having trouble in retrieving
the values from the from the dynamically added text fields. Can anyone
please help me in solving this problem.

Sample code of my HTML page:


<html>
<head></head>

<script type="text/javascript">
var createRow=true;
function fAddRow () {

  var table;
 
  if (document.all)
     table = document.all.namesTable;
   else
     table = document.getElementById('namesTable');
	if(table.rows.length>1){
		rowindex=table.rows.length-2;
		createRow=fCheckEmptyInlineFields();
	}
   if(createRow){
     if (table && table.insertRow) {
       var row = table.insertRow(table.rows.length);
		 var cell0 = row.insertCell(0);
		 cell0.align="center";
		 cell0.innerHTML = '<input type="text" wicket:id="firstname"
name="firstname" value="" size="12" class=txtsv />';

		 var cell1 = row.insertCell(1);
		 cell1.align="center";
		 cell1.innerHTML = '<input type="text" wicket:id="lastname"
name="lastname" value="" size="12" class=txtsv />';

	}
   }
   
}


</script>
<body>
<form wicket:id="dynamicform">
	 <TABLE BORDER="1" CELLPADDING="0" id="namesTable" CELLSPACING="4"
ALIGN="CENTER" CLASS="EmpLkBody">
				
				<thead>
				  <TR >
				   <TD CLASS="TrackHeaderRow" ALIGN=CENTER>First name</TD>
				   <TD CLASS="TrackHeaderRow" ALIGN=CENTER>Last Name</TD>
				  </TR>
				</thead>
				<TR>
				<TD ALIGN=CENTER><input type="text" wicket:id="firstname"
name="firstname"/></TD>
				<TD ALIGN=CENTER><input type="text" wicket:id="lastname"
name="lastname"/></TD>
				</TR>
				</TABLE>
				<Div id="tablebody" STYLE="display: inline;">
				<TABLE cellpadding="0" cellspacing="4" border="0" align="center"
width="100%" height="1%" CLASS="EmpLkBody">
				<TR>
			    <TD colspan=2 CLASS=labelSM ALIGN="CENTER"><INPUT TYPE="button"
value="ADD&nbsp;ROW" name="addRow" onclick="fAddRow();" style="width: 60px;"
class="txtsv"/></TD>
		     	</TR>
		    </TABLE>
		    </Div>
</form>
</body>
</html>

Thanks in Advance
Anuradha
-- 
View this message in context: http://www.nabble.com/Problem-in-retrieving-the-dynamic-text-field-values-tf4136264.html#a11764055
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: Problem in retrieving the dynamic text field values

Posted by "anuradha.g" <ga...@prokarma.com>.

Hi Igor,

 Thanq very much for your suggestion, it solved my problem, but a small
correction 
I used String[] lastnames = getRequest.getParameters("lastnames");

Thanq
Anuradha


igor.vaynberg wrote:
> 
> since you are adding those fields in javascript andnot in wicket then:
> 1) remove wicket:id attribute from the textfield
> 2) in form.onsubmit do String[]
> lastnames=getRequest().getParameters().get("lastname");
> thats it
> 
> -igor
> 
> 
> On 7/24/07, anuradha.g <ga...@prokarma.com> wrote:
>>
>>
>> Hi,
>> I'm a newbie in wicket. Can any one please help me in solving my problem
>>
>> In HTML page, I'm adding wicket textfields to the table dynamically using
>> java script (on every click of ' 'Add Row' button, a new row of wicket
>> text
>> fields is added to the table dynamiccaly) . I'm having trouble in
>> retrieving
>> the values from the from the dynamically added text fields. Can anyone
>> please help me in solving this problem.
>>
>> Sample code of my HTML page:
>>
>>
>> <html>
>> <head></head>
>>
>> <script type="text/javascript">
>> var createRow=true;
>> function fAddRow () {
>>
>>   var table;
>>
>>   if (document.all)
>>      table = document.all.namesTable;
>>    else
>>      table = document.getElementById('namesTable');
>>         if(table.rows.length>1){
>>                 rowindex=table.rows.length-2;
>>                 createRow=fCheckEmptyInlineFields();
>>         }
>>    if(createRow){
>>      if (table && table.insertRow) {
>>        var row = table.insertRow(table.rows.length);
>>                  var cell0 = row.insertCell(0);
>>                  cell0.align="center";
>>                  cell0.innerHTML = '<input type="text"
>> wicket:id="firstname"
>> name="firstname" value="" size="12" class=txtsv />';
>>
>>                  var cell1 = row.insertCell(1);
>>                  cell1.align="center";
>>                  cell1.innerHTML = '<input type="text"
>> wicket:id="lastname"
>> name="lastname" value="" size="12" class=txtsv />';
>>
>>         }
>>    }
>>
>> }
>>
>>
>> </script>
>> <body>
>> <form wicket:id="dynamicform">
>>          <TABLE BORDER="1" CELLPADDING="0" id="namesTable"
>> CELLSPACING="4"
>> ALIGN="CENTER" CLASS="EmpLkBody">
>>
>>                                 <thead>
>>                                   <TR >
>>                                    <TD CLASS="TrackHeaderRow"
>> ALIGN=CENTER>First name</TD>
>>                                    <TD CLASS="TrackHeaderRow"
>> ALIGN=CENTER>Last Name</TD>
>>                                   </TR>
>>                                 </thead>
>>                                 <TR>
>>                                 <TD ALIGN=CENTER><input type="text"
>> wicket:id="firstname"
>> name="firstname"/></TD>
>>                                 <TD ALIGN=CENTER><input type="text"
>> wicket:id="lastname"
>> name="lastname"/></TD>
>>                                 </TR>
>>                                 </TABLE>
>>                                 <Div id="tablebody" STYLE="display:
>> inline;">
>>                                 <TABLE cellpadding="0" cellspacing="4"
>> border="0" align="center"
>> width="100%" height="1%" CLASS="EmpLkBody">
>>                                 <TR>
>>                             <TD colspan=2 CLASS=labelSM
>> ALIGN="CENTER"><INPUT TYPE="button"
>> value="ADD&nbsp;ROW" name="addRow" onclick="fAddRow();" style="width:
>> 60px;"
>> class="txtsv"/></TD>
>>                         </TR>
>>                     </TABLE>
>>                     </Div>
>> </form>
>> </body>
>> </html>
>>
>> Thanks in Advance
>> Anuradha
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-in-retrieving-the-dynamic-text-field-values-tf4136264.html#a11764055
>> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-in-retrieving-the-dynamic-text-field-values-tf4136264.html#a11776642
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: Problem in retrieving the dynamic text field values

Posted by Igor Vaynberg <ig...@gmail.com>.
since you are adding those fields in javascript andnot in wicket then:
1) remove wicket:id attribute from the textfield
2) in form.onsubmit do String[]
lastnames=getRequest().getParameters().get("lastname");
thats it

-igor


On 7/24/07, anuradha.g <ga...@prokarma.com> wrote:
>
>
> Hi,
> I'm a newbie in wicket. Can any one please help me in solving my problem
>
> In HTML page, I'm adding wicket textfields to the table dynamically using
> java script (on every click of ' 'Add Row' button, a new row of wicket
> text
> fields is added to the table dynamiccaly) . I'm having trouble in
> retrieving
> the values from the from the dynamically added text fields. Can anyone
> please help me in solving this problem.
>
> Sample code of my HTML page:
>
>
> <html>
> <head></head>
>
> <script type="text/javascript">
> var createRow=true;
> function fAddRow () {
>
>   var table;
>
>   if (document.all)
>      table = document.all.namesTable;
>    else
>      table = document.getElementById('namesTable');
>         if(table.rows.length>1){
>                 rowindex=table.rows.length-2;
>                 createRow=fCheckEmptyInlineFields();
>         }
>    if(createRow){
>      if (table && table.insertRow) {
>        var row = table.insertRow(table.rows.length);
>                  var cell0 = row.insertCell(0);
>                  cell0.align="center";
>                  cell0.innerHTML = '<input type="text"
> wicket:id="firstname"
> name="firstname" value="" size="12" class=txtsv />';
>
>                  var cell1 = row.insertCell(1);
>                  cell1.align="center";
>                  cell1.innerHTML = '<input type="text"
> wicket:id="lastname"
> name="lastname" value="" size="12" class=txtsv />';
>
>         }
>    }
>
> }
>
>
> </script>
> <body>
> <form wicket:id="dynamicform">
>          <TABLE BORDER="1" CELLPADDING="0" id="namesTable" CELLSPACING="4"
> ALIGN="CENTER" CLASS="EmpLkBody">
>
>                                 <thead>
>                                   <TR >
>                                    <TD CLASS="TrackHeaderRow"
> ALIGN=CENTER>First name</TD>
>                                    <TD CLASS="TrackHeaderRow"
> ALIGN=CENTER>Last Name</TD>
>                                   </TR>
>                                 </thead>
>                                 <TR>
>                                 <TD ALIGN=CENTER><input type="text"
> wicket:id="firstname"
> name="firstname"/></TD>
>                                 <TD ALIGN=CENTER><input type="text"
> wicket:id="lastname"
> name="lastname"/></TD>
>                                 </TR>
>                                 </TABLE>
>                                 <Div id="tablebody" STYLE="display:
> inline;">
>                                 <TABLE cellpadding="0" cellspacing="4"
> border="0" align="center"
> width="100%" height="1%" CLASS="EmpLkBody">
>                                 <TR>
>                             <TD colspan=2 CLASS=labelSM
> ALIGN="CENTER"><INPUT TYPE="button"
> value="ADD&nbsp;ROW" name="addRow" onclick="fAddRow();" style="width:
> 60px;"
> class="txtsv"/></TD>
>                         </TR>
>                     </TABLE>
>                     </Div>
> </form>
> </body>
> </html>
>
> Thanks in Advance
> Anuradha
> --
> View this message in context:
> http://www.nabble.com/Problem-in-retrieving-the-dynamic-text-field-values-tf4136264.html#a11764055
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>