how can i separate an iterated struts radio button item? - struts2

How can i separate an iterated struts radio button item?
I also tried using some of these
,but probably in the wrong way.
What i wish to do is separate each item from the first iterator (the paths), with a <br> or any separator.
I guess this is happening because the html tags are interpreted first, before the struts tags?
<s:form action="actionConfirmBooking">
<s:iterator var = "pathList" value="results">
<s:iterator var = "flightList" value="pathList">
<s:radio name="flightSelected" list="flightList" listKey = "flightid" id = "flightid" value = "flightid"/>
$$$$$$$$$$$
</s:iterator>*************
</s:iterator>&&&&&&&&
<s:submit label="Submit" />#############
</s:form>

Use theme="simple" to prevent Struts generating additional XHTML code by using the default theme (XHTML):
<s:form action="actionConfirmBooking" theme="simple">
...
</s:form>

Related

dynamic data reload to struts2 jquery grid on form submit

I have a grid which load data on page load.
I also have a form that on submit calls an action correctly, but it doesn't load new data on my grid.
List is correctly geting and also correctly setting in my grid model From my Action class but while on return SUCCESS it simply returns data in this form(see below output)...
{"authFirstname":null,"authLastname":null,"bookDetailsobj":null,"bookTitile":null,"get":{"authFirstname":null,"authLastname":null,"bookTitile":null,"coverId":null,"createdDate":null,"createrId":null,"description":null,"editionId":null,"editionYear":null,"id":null,"img1":null,"img2":null,"isbn":null,"languageId":null,"locationId":null,"price":null,"publisherName":null,"quantity":null,"remarks":null,"subjectId":null,"updateId":null,"updatedDate":null,"videoUrl":null},"gridModel":[{"authFirstname":"234234","authLastname":"2323423","bookTitile":"23324234234","coverId":"soft cover","description":"243234","editionId":"General Edition","editionYear":"234234","id":42,"img1":"","img2":"","isbn":"324234","languageId":"English","locationId":"as","price":2.34234E7,"publisherName":"234234","quantity":234234,"remarks":"","subjectId":"General Fiction","videoUrl":""},{"authFirstname":"2423","authLastname":"23423","bookTitile":"asdfsdaf","coverId":"soft cover","description":"","editionId":"General Edition","editionYear":"2","id":39,"img1":"","img2":"","isbn":"2","languageId":"English","locationId":"as","price":234.0,"publisherName":"2","quantity":2,"remarks":"","subjectId":"General Fiction","videoUrl":""},{"authFirstname":"3","authLastname":"3","bookTitile":"232","coverId":"soft cover","description":"","editionId":"General"}
My jsp code:
<sjg:grid
id="getLogs"
dataType="json"
href="%{getCurrentDateLogs}"
gridModel="listOfLogs"
onSelectRowTopics="rowselect"
loadonce="true"
reloadTopics="reloadGrid"
formIds="form2"
>
<sjg:gridColumn name="userid" index="userid" title="User ID" sortable="true" align="center"/>
<sjg:gridColumn name="username" index="username" title="Username" sortable="true"/>
<sjg:gridColumn name="logaction" index="logaction" width="600" title="Action" sortable="true"/>
<sjg:gridColumn name="date" index="date" title="Date" sortable="true" sorttype="date" align="center"/>
<sjg:gridColumn name="time" index="time" title="Time" sortable="true" sorttype="time" align="center"/>
</sjg:grid>
<s:form action="getLogsByDates" id="form2" theme="simple" cssClass="yform">
<table class="">
<tr><td>from:</td>
<td><sj:datepicker value="yesterday" id="from" name="startDate" displayFormat="dd/mm/yy" label="from" /></td>
</tr>
<tr><td>to:</td>
<td><sj:datepicker value="today" id="to" name="endDate" displayFormat="dd/mm/yy" label="to" /></td>
</tr>
<tr><td colspan="2">
<sj:submit
value="Search"
button="true"
onClickTopics="reloadGrid"
indicator="indicator"
/>
</td></tr>
</table>
</s:form>
struts.xml
<action name="getLogsByDates" class="v.esoft.actions.bookdetails.BookdetailsAction" >
<result name="success" type="json"/>
<result name="login" type="redirect"> /index.jsp </result>
</action>
**
I don't know why my output is not showing in my jquery grid. Please help me**
I guess this is what you require :
Instead of using a sj:submit tag, use a sj:a tag with onClickTopics pointing to GridReloadTopics.
Then when sj:a is clicked, the grid get's reloaded, submitting the form to action defined in href attribute of grid.
This action must result a JSON which will populate the grid.
You haven't shown the action "getCurrentDateLogs" in the question. So this is the action that must return the json result populating the grid.
Also you must be thinking that how the grid-data gets affected by the form fields, so it's easy
The grid submits all the form fields to the action mentioned in href, so you must be having a getter & setter for every form field on that action.
Along with other normal grid attributes, now you'll receive the additional form attributes, based on the value of which you'll fill up the gridModel.
Please let me know if you still didnt' understood.
It doesn't work this way. try do the following things:
make an action retuen a page, not json
<result name="success">page_with_the_grid.jsp</result>
on the page page_with_the_grid.jsp, use s:url tag to map your json result:
<s:url var="jsonUrl" action="jsonAction"/>
in your sj:grid, use href="%{jsonUrl}" to fill your data to the grid.
if you directly call the action, which returns JSON, you will sure get a json result, which is your "Strange" output.
I have find Two grid after submit the form one is old one and second one my search grid it also include whole page
<sj:a href="%{form}" targets="result" indicator="indicator" button="true" buttonIcon="ui-icon-refresh"/>

How to get the checked Checkbox values from GSP to java script

Hi I am new to grails and GSP
I have a code like
<g:each var="i" in="${typeList}">
<g:if test="${i != null}">
<tr>
<td><input type="checkbox" name="categoryType" id="categoryTypeCB" class="categoryTypeCB" value="${i}"> ${i}</td>
</tr>
</g:if>
</g:each>
How to get the values of checked check boxes in java script
Try to use jQuery. Since Grails 2.0 it's provided by default, you just have to add in your gsp template at the end of head tag with following line:
<r:require module="jquery" />
Or if you do not use resources plugin, include jQuery with following line:
<g:javascript library='jquery' />
And then in a javascript block go with:
<g:javascript>
var checkedCheckboxes = $('.categoryTypeCB:checked');
$.each(checkedCheckboxes, function(index, checkbox) {
var theValue = checkbox.value;
});
</g:javascript>
The each funciton is a loop so you need to handle somehow 'theValue' each iteration. The checkbox argument contains the input element itself if you need it.
BTW. You shouldn't assign the same id for many inputs. It's incorrect. Id has to be unique for each HTML element among document tree.

Struts2 : Double Iteration over Parameters does not work?

Hello I am a young Software developer,
and I struggled the last 5 days with my code.
Here is my code in JSP:
<s:iterator value="getListeDanach()" status="stat">
<li>
<s:url id="URL_ListeDanach" action="uebersicht_umblaettern">
<s:param name="angeklickteSeitenzahl" value="getListeDanach()[#stat.index]" />
<s:bean name="org.apache.struts2.util.Counter" var="counter">
<s:param name="last" value="3" />
</s:bean>
<s:iterator value="#counter" status="stat1">
<s:property value="#stat1.index" />
<s:param name="%{optionaleParamName4}" value="#optionaleParamValue4" />
</s:iterator>
</s:url>
<s:a href="%{URL_ListeDanach}" cssClass="naviTab">
<s:property value="getListeDanach()[#stat.index]" />
</s:a>
</li>
</s:iterator>
My problem is, the first Iteration works great but the 2nd Iteration works half. In the 2nd case the property works, but the param doesn´t work! Al Variables are available. If i take the param Tag of the 2nd Iteration and place it in the first, it works great! But that isn´t what I want.
This is not an answer.
Here's the JSP, cleaned up, and using more S2 functionality. It was impossible to read the original.
<s:iterator value="listeDanach" status="stat" var="outerItem">
<li>
<s:url id="URL_ListeDanach" action="child">
<s:param name="angeklickteSeitenzahl" value="outerItem" />
<%-- What are you trying to do here? --%>
<s:bean name="org.apache.struts2.util.Counter" var="counter">
<s:param name="last" value="3" />
</s:bean>
<%-- What are you trying to do here? There's nothing to iterate over. --%>
<s:iterator value="#counter" status="stat1">
<s:property value="#stat1.index" />
<s:param name="%{optionaleParamName4}" value="#optionaleParamValue4" />
</s:iterator>
</s:url>
<s:a href="%{URL_ListeDanach}">
<s:property value="outerItem" />
</s:a>
</li>
</s:iterator>
In the bean i have a loop with 3 "rounds", in the 2nd iterator i use the var=counter to iterate three times over the property and over the dynamic parameter.
The property shows in HTMl in every loop of the first iterator this result : 0 1 2;
This is how it should work(the property is just there, to test the functionality of the 2nd itarator.)
But in the 2nd case, the parameter-Tag is fully ignored or something like that. For those who want to know the logic behind the code. It is a side navigation bar. listeDav or = list behind the actual number, and listeDanach= list after the actual number. 1 2 3 4 [5] 6 7 8 9.... When the param Tag in the 2nd itarator functions well, I would make the param tag dynamically with the iterated index.
SO in short, what I want is: Every time the first Iterator has his loop, I want to create dynamic parameters. This parameters are defined in the JSP before and are fully supported! I want to use the index "#stat1.index" to make it work.
Something like this :
s:param name="%{optionaleParamName[#stat1.index]}" value="#optionaleParamValue[#stat1.index]" />.....
i have already defined the String behind "#optionaleParamValue[0], behind #optionaleParamValue[1] and behind #optionaleParamValue[2] and soo on... ... and all this is for reusing the actual JSP.
As you can mention, a side navigation bar, can be used in many other cases in the programm.
Greetings

Struts 2 iterator tag status index is not working

<s:iterator value="podTemplate.subTypeTemplates" status="subTemplate">
<s:textfield id='subType_type_#subTemplate.index' key="subType" label="Name"/>
</s:iterator>
#subTemplate.index is not getting replaced by index. However if I am doing
<s:property value="#subTemplate.index"> is working
That's because id attribute of textfield is of string type and string-type attributes are not interpreted as OGNL by default. As Steven said you have to force the interpretation by using %{} in your case subType_type_%{#subTemplate.index}.
My iterator looks like this:
<s:iterator id="list" value="optionList" status="rowStatus" >
I tried:
<td>
<input class="textInput required"type="text" name="optionList[${rowStatus.index}].option_id"/>
</td>
and it's the only one that worked.
All the following ones failed:
name="optionList[%{#rowStatus.index}].option_id"
name="%{optionList[#rowStatus.index].option_id}"
even
name="%{#rowStatus.index}"

Property value in <s:textfield> struts2

How to set propety value in <s:textfield>
I tried <s:textfield name="customerName" label="Customer Name" value='<s:property value="userInfo.customerName"' /> but it didn't work.
Please help
You can not use a tag inside of a tag. Use OGNL instead!
<s:textfield name = "customerName"
label = "Customer Name"
value = "%{userInfo.customerName}"/>
Use OGNL (Object Graph Navigation Language) to get value in any kind of field of struts. If you will not get value please check setter and getter of the variable.
<s:textfield name="transValueChange" id="transValueChange"
value ="%{transValue}" theme="simple" maxLength="30"
onkeypress="return isNumberKey(event)">
</s:textfield>
OR
<s:select name="propCode" id="propCode" list="propClassMasMap" theme="simple"
value="%{propCode}" onchange="" cssClass="text">
</s:select>
I used this:
<table>
<s:label>User Name:</s:label>
<s:textfield name="user.userid" cssClass="tb5" type="text" placeholder="User Name" value="%{#session.userid}" disabled="true" />
</table>
The disabled attribute is not mandatory, I used it to disable the textfield that way the values will be retrieved from the DB and will be disable for the user to make changes on it.

Resources