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"/>
I've a test.jsp which includes an html.using the following tag
<s:form action="showTrainingPage">
<s:include value="%{objBarcodeCertificationTaskForm.strTrainingPage}"></include>
<s:submit type="image" src="../../images/next.png"/>
</s:form>
The value is developed dynamically in action.
<action name="showTrainingPage" method="getTrainingDetails" class="certificationTask">
<result name="input" >test.jsp</result>
</action>
But this does not help. When i click on Next, it says the requested source is not available. Please let me know how can this be solved.
i've got a form with 3 fields, two String (one select and a text field) and an int. When i put a letter or something else than an int (52.4 or aaa) in the field i got an error that i cannot "catch", my select disapear and on the message box i ve got a message from my validation xml file (in french) and another one in english (i suppose sent by struts).
error in tomcat :
(ognl.OgnlValueStack 60 ) Error setting expression 'userSize' with value '[Ljava.lang.String;#14aa6c3'
error on message box :
Invalid field value for field "userSize".
test size
JSP code :
<s:form action="sendUserCreation" method="POST">
<s:action namespace="/" name="civilityPicklist" executeResult="true"/><br />
<s:textfield name="lastName" /><br />
<s:textfield name="userSize" /><br />
struts.xml code :
<action name="createUser">
<result>/jsp/user/create.jsp</result>
</action>
<action name="sendUserCreation" class="fr.action.UserAction" method="createUser">
<result>/jsp/splash.jsp?messKey=${messKey}</result>
<result name="input">/jsp/user/create.jsp</result>
</action>
<action name="civilityPicklist" class="fr.imaps.oxygene.portal.action.CivilityPicklistAction">
<result>/jsp/user/civilityPicklist.jsp</result>
</action>
UserAction-validation.xml code:
<validators>
<field name="userSize">
<field-validator type="conversion">
<message>test size</message>
</field-validator>
</field>
</validators>
UserAction code :
private int userSize;
public int getUserSize() {
return userSize;
}
public void setUserSize(int userSize) {
this.userSize = userSize;
}
I thought the "conversion" validation type will "catch" this kind of problem but it seems not... what's wrong with my code ?
I've been taking a quick look at this and I think that the reason for the double message is that, in my case at least, it looks like conversion errors may be being handled twice, firstly by the StrutsConversionErrorInterceptor and again by the AnnotationValidationInterceptor. Both these interceptors are in the struts-default stack.
Removing the StrutsConversionErrorInterceptor from the stack removes the Struts generated message and leaves the user defined message as the only error message displayed. However, I've not had time yet to investigate any other side consequences of removing this inreceptor.
I have a question, but I couldn't find a solution for my problem in Korean web community.
<s:form name="form1" method="post" action="products" theme="simple">
<s:hidden name="code" value="%{code}"/>
<s:submit type="button" name="method:selectSale" value="goPage"/>
</s:form>
This code has no problem.
But, I want to use "anchor" instead of "submit" tag. I just want to use hyperlink and 'post' way, not 'get'. How can I do this? Help me please~ :)
<s:form name="form1" method="post" action="products" theme="simple">
<s:hidden name="code" value="%{code}"/>
goPage
</s:form>
It doesn't work. :(
The main problem is how to get "method:selectSale".
in struts.xml,
<action name="products" class="sample.ProductsAction">
<result>abc.jsp</result>
<result name="selectSale">selectSale.jsp</result>
</action>
and then, in ProductsAction.java,
public String selectSale() throws Exception {
// ~~~
return "selectSale"
}
Ok, now, I have a question.
where do i have to put "selectSale" on code? ( using <s:a> or <a:> )
Define a and use it in your anchor.
<s:url id='IdAnchor' action='products' method='selectSale'/>
goPage
Regards,
In my struts2 application I am using “File Upload Interceptor”. Its running well but after uploading when same jsp page appears it does not show browsed file name in the textbox of <s:file> tag i.e textbox comes empty after successful uploading.
Here is my code snippet-
main.jsp
<s:form action="smAction" enctype="multipart/form-data" theme="simple">
<s:file name="sample"/>
<s:submit action="uploadSample" value="All upload" />
</s:form>
struts.xml
<action name=" uploadSample " class=" UploadMySample">
<interceptor-ref name="defaultStack"/>
<result name="input"> /login.jsp</result>
<result name="success">/main.jsp</result>
</action>
UploadMySample.java
public class UploadMySample extends ActionSupport {
private File sample;
private String sampleContentType;
private String sampleFileName;
public File getSample () {
return sample;
}
public void setSample (File sample) {
this. sample = sample;
}
//Here is the file uploading code
return SUCCESS;
}
Please suggest.
This is not a problem of Struts. For security reasons modern browser don't allow to set a value for file upload fields. If you want to display the file name after the upload you'll have to use simple text.