How to send multiple objects from jsp files - spring-mvc

I want to send multiple objects from jsp file using commandname in spring form
I have searched on google and explored various sites but found no solutions of this problem
<form:form action="addproductLED"method="post"commandname="addProductLed">
<div align="center">
<h2 class="ledtechdetails">Add Led</h2>
</div>
<div style="margin-top:25px;margin-bottom:25px;">
<table border="0" cellpadding="10" cellspacing="10" class="addledtable">
<tr class="add-led">
<td class="add-led">Product Category :</td>
<td class="add-led">
<select id="productCatId"name="productCatId"class="protechname"onchange="showled('led')" required>
</tr>
<tr class="add-led">
<td class="add-led">Product Name :</td>
<td class="add-led">
<input type="text" name="productName" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Stock :</td>
<td class="add-led"><input type="number" name="productStock" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product SKU :</td>
<td class="add-led"><input type="text" name="productsku" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product MRP :</td>
<td class="add-led"><input type="number" name="productMrp" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Price :</td>
<td class="add-led"><input type="number" name="productprize" required class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Product Size :</td>
<td class="add-led"><input type="text" name="productsize" class="protechname"/></td>
</tr>
<!-- another model class configuration -->
<tr class="add-led">
<td class="add-led">Resolution :</td>
<td class="add-led"><input type="text" name="resolution" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Port :</td>
<td class="add-led">
<input type="text" name="port" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Wifi Type :</td>
<td class="add-led"><input type="text" name="type" class="protechname"/></td>
</tr>
<tr class="add-led">
<td class="add-led">Operating System :</td>
<td class="add-led"><input type="text" name="operatingSystem" class="protechname"/></td>
</tr>
I want to get model class object in Spring Controller but I dont know how to send two model class object from one single jsp page

You can transfer multiple objects using commandname separated by semi-colon,
You have to change
<form:form action="addproductLED"method="post"commandname="addProductLed">
to
<form:form action="addproductLED" method="post" commandname="addProductLed,anotherObject" enctype="multipart/form-data">
It will send multiple object.

Related

Bootstrap table with certain rows different widths

I have a table:
<table class="table table-bordered">
<tr>
<th class="text-center" colspan="3">
DRUG INFO
</th>
</tr>
<tr>
<td class="col-md-4"><span>{{item.fields[18].displayName}}</span></td>
<td class="col-md-3"><span>{{item.fields[25].displayName}}</span></td>
<td class="col-md-5"><span>{{item.fields[14].displayName}}</span></td>
</tr>
<tr>
<td>
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[19].htmlName)" data-strat-model="item" data-field="item.fields[18]"></div>
</td>
<td>
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[26].htmlName)" data-strat-model="item" data-field="item.fields[25]"></div>
</td>
<td>
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[15].htmlName)" data-strat-model="item" data-field="item.fields[14]"></div>
</td>
<tr>
<td colspan="1">UD_UU_PKG</td>
<td></td>
<td colspan="1">SHORT_CYCL</td>
</tr>
<tr>
<td>
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[52].htmlName)" data-strat-model="item" data-field="item.fields[52]"></div>
</td>
<td>
</td>
<td>
<div data-strat-form-control data-field-display-id="20" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[53].htmlName)" data-strat-model="item" data-field="item.fields[53]"></div>
</td>
</tr>
</tr>
</table>
Currently it looks like this:
I am trying to figure out how to make the middle cell on the bottom 2 rows go away so that the 2 fields will be equal in size (50/50). I have tried a ton of html properties (width, colspan etc) as well as trying to manipulate the columns with bootstrap (class="col-md-6").
What am I doing wrong and how do I fix it?
EDIT: This is what I get with Banzay's recommendations:
You need to plan the table that contains of 4 cells in each row, than set colspan respectively.
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-bordered">
<tr>
<th class="text-center" colspan="4">
DRUG INFO
</th>
</tr>
<tr>
<td class="col-md-4"><span>{{item.fields[18].displayName}}</span></td>
<td class="col-md-3" colspan="2"><span>{{item.fields[25].displayName}}</span></td>
<td class="col-md-5"><span>{{item.fields[14].displayName}}</span></td>
</tr>
<tr>
<td>
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[19].htmlName)" data-strat-model="item" data-field="item.fields[18]"></div>
</td>
<td colspan="2">
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[26].htmlName)" data-strat-model="item" data-field="item.fields[25]"></div>
</td>
<td>
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[15].htmlName)" data-strat-model="item" data-field="item.fields[14]"></div>
</td>
<tr>
<td colspan="2">UD_UU_PKG</td>
<td colspan="2">SHORT_CYCL</td>
</tr>
<tr>
<td colspan="2">
<div data-strat-form-control data-field-display-id="1" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[52].htmlName)" data-strat-model="item" data-field="item.fields[52]"></div>
</td>
<td colspan="2">
<div data-strat-form-control data-field-display-id="20" data-vmformreadonly="formReadOnly" data-show-tool-tip="showToolTip(item.fields[53].htmlName)" data-strat-model="item" data-field="item.fields[53]"></div>
</td>
</tr>
</table>
Just play with colspans:
<table>
<tr>
<th colspan="6">
DRUG INFO
</th>
</tr>
<tr>
<td colspan="2">Effective date</td>
<td colspan="2">Minimum order</td>
<td colspan="2">Total package</td>
</tr>
<tr>
<td colspan="2">
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<td colspan="2">
<input type="text">
</td>
<tr>
<td colspan="3">UD_UU_PKG</td>
<td colspan="3">SHORT_CYCL</td>
</tr>
<tr>
<td colspan="3">
<input type="text">
</td>
<td colspan="3">
<input type="checkbox">
</td>
</tr>
</table>
And don't use "col-*-*" classes with table columns. They are designed to build responsive grids.

Toggle radio buttons between to different sets

I would like to toggle selection between two different sets of radio buttons.
The condition that must be met is that if the user checks the button on one set (called in the example l1), it is unchecked in the other set (called in the example m1).
In other questions, it seems that it is only feasible solution is using Java scripts.
Below is the code:
<table border="0" cellpadding="1" cellspacing="1" style="width: 500px;">
<tbody>
<tr>
<td style="width: 300px;"> </td>
<td style="width: 100px; text-align: center;">Least</td>
<td style="width: 100px; text-align: center;">Most</td>
</tr>
<tr>
<td>{{question1}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-1" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="1" /></td>
</tr>
<tr>
<td>{{question2}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-2" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="2" /></td>
</tr>
<tr>
<td>{{question3}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-3" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="3" /></td>
</tr>
<tr>
<td>{{question4}}</td>
<td style="text-align: center;"><input name="l1" type="radio" value="-4" /></td>
<td style="text-align: center;"><input name="m1" type="radio" value="4" /></td>
</tr>
</tbody>

How to have a struts2 form in a table?

I am trying to have my form in a table but it generates a table and makes it a mess.
the generated table is as following:
<div>
<s:form action="myaction" >
<table border="1">
<tr>
<td><s:textfield name="name" label="Name" /></td>
<td><s:textfield name="family" label="Family" /></td>
<td><s:submit/></td>
</tr>
</table>
</s:form>
</div>
Source code :
<div>
<form id="myaction" name="myaction" action="/application/myaction.action" method="post">
<table class="wwFormTable"> <<<generated table
<table border="1">
<tr>
<td><tr>
<td class="tdLabel"><label for="Search_Name" class="label">Name:</label></td>
<td
><input type="text" name="Name" value="" id="Search_Name"/></td>
</tr>
</td>
<td><tr>
<td class="tdLabel"><label for="Search_Family" class="label">Family:</label></td>
<td
><input type="text" name="Family" value="" id="Search_Family"/></td>
</tr>
</td>
<td><tr>
<td colspan="2"><div align="right"><input type="submit" id="Search_0" value="Submit"/>
</div></td>
</tr>
</td>
</tr>
</table>
</table></form>
Use the "simple" theme if you do not want to use S2's default "xhtml" theme.
You'll lose S2's automatic error reporting. You may wish to consider creating your own theme.
Alternatively, you can use the "simple" theme on individual controls.
See the "Themes and templates" docs to get started.
Try to use any theme in struts form tag
eg:
<s:form action="Courses" theme="css_xhtml">
<table border="0">
<tr>
<td><s:textfield name="courseAbbr" /></td>
</tr>
</table>
</s:form>
May Be you should use this code instead...
<sp:form >
<tr>
<td>
<table>
<sp:textfield name="name"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:textfield name="family"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:submit/>
</table>
</td>
</tr>
</sp:form>

How do I use html decode in my view page?

My engine is Aspx.
I am currently having trouble editing one of my columns(Question Answer) in my table because it has html tags in it. Is there a way I can decode only that specific row/column in the value area?
<form id="updateFreqQuestionsUser" action="<%=Url.Action("SaveFreqQuestionsUser","Prod")%>" method="post">
<table>
<tr>
<td colspan="3" class="tableHeader">Freq Questions User Details <input type ="hidden" value="<%=freqQuestionsUser.freqQuestionsUserId%>" name="freqQuestionsUserId"/> </td>
</tr>
<tr>
<td colspan="2" class="label">Question Description:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionDescription" value="<%=freqQuestionsUser.questionDescription%>" />
</td>
</tr>
<tr>
<td colspan="2" class="label">QuestionAnswer:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionAnswer" value="<%=freqQuestionsUser.questionAnswer%>" />
</td>
</tr>
<tr>
<td colspan="3" class="tableFooter">
<br />
<a id="freqQuestionsUserUpdateButton" href="#" class="regularButton">Save</a>
Cancel
</td>
</tr>
</table>
Yes, you can do this:
<input type="text" maxlength="2000" name="QuestionAnswer"
value="<%=Server.HtmlDecode(freqQuestionsUser.questionAnswer)%>" />
Reference

How to disable all td tag in jsp using css

I have a form that is in jsp at one condition the user click to view the form. When the form is render the information contain in the form should not be editable all the td should be visible but should not be editable.
for example:-
<table width="600" align="center" >
<tr>
<td class="td_left_b" width="30%">Company Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.companyName}" id="companyName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Hotel Name(Display Name):</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.hotelName}" id="hotelName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Country:</td>
<td width="60%" height="25"><input type="text" size="28" value="" id="country"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">City:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.cityName}" id="cityName"/></td></tr>
<tr>
<td class="td_left_b" width="30%">NeighbourhoodName:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.neighbourhoodName}" id="neighbourhoodName"/></td>
</tr>
<tr>
<td class="td_left_b" width="30%">Street Name:</td>
<td width="60%" height="25"><input type="text" size="28" value="${com.streetName}" id="streetName"/></td>
</tr>
</table>
The above information i am putting through spring MODEL ATTRIBUTE in respective td. i dont want to be editable the information.
Thanks.
You cannot disable Tablecolumns. You have to disable evere input in your table.

Resources