I'm working on a project with struts2 and dojo. Our dojo version is 1.4.x
I can't submit a form with DateTextBox control when my browser language is English.
However, when I change the local into other language like ZH_CN, it works.
I'm wondering why this would happen.
Here is my jsp code snippet:
<div id="projectForm" dojotype="dijit.form.Form">
<!-- end Date -->
<span class="manager_create_from_components">
<s:text name="manager.create.endDate"></s:text>
</span>
<input type="text" name="project.endDate" constraints="{datePattern:'yyyy-MM-dd'}" dojotype="dijit.form.DateTextBox"><br />
</div>
Thanks for you help.
HTTP Status 404 - No result defined for action
com.ternwit.tms.web.action.ManagerAction and result input.
This error is due to the fact you don't specified a result page in your struts.xml
<action name="actionName" class="package.yourClass" method="yourMethod">
<result name="success">successPage.jsp</result>
<result name="error">errorPage.jsp</result>
<result name="input">errorPage.jsp (or yourFormPage.jsp)</result>
</action>
Hope this helped
And about the dateTextBox, I have the same problem as you have. I think it's because of the value returned. Ex : "Wed Nov 16 2011 00:00:00 GMT+0100"
Related
I am following the Moqui getting started tutorial. I have created a create form as below.
<?xml version="1.0" encoding="UTF-8"?>
<screen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://staging.azpire.co.in/xsd/xml-screen-2.1.xsd"
require-authentication="anonymous-all">
<transition name="findTutorial"><default-response url="."/></transition>
<transition name="createTutorial">
<service-call name="create#tutorial.Tutorial"></service-call>
<default-response url="."/>
</transition>
<actions>
<entity-find entity-name="tutorial.Tutorial" list="tutorialList">
<search-form-inputs/>
</entity-find>
</actions>
<widgets>
<container-dialog button-text="Create Tutorial" id="CreateTutorialDialog">
<form-single name="CreateTutorial" transition="createTutorial">
<auto-fields-entity entity-name="tutorial.Tutorial" field-type="edit"/>
<field name="submitButton">
<default-field title="Create"><submit/></default-field>
</field>
</form-single>
</container-dialog>
<form-list name="ListTutorials" list="tutorialList" transition="findTutorial">
<auto-fields-entity entity-name="tutorial.Tutorial" field-type="find-display"/>
</form-list>
</widgets>
</screen>
When I click "Create Tutorial", the form shows up. But, it is disabled(read only) including the submit button.
If you are following the Moqui getting started tutorial, you need import data about security screen as follow to fix this problem:
<moqui.security.ArtifactGroup artifactGroupId="TUTORIAL" description="Tutorial"/>
<moqui.security.ArtifactGroupMember artifactGroupId="TUTORIAL" artifactTypeEnumId="AT_XML_SCREEN"
inheritAuthz="Y" artifactName="component://tutorial/screen/tutorial.xml"/>
<!-- Full permissions for the ADMIN user group -->
<moqui.security.ArtifactAuthz artifactAuthzId="TUTORIAL_AUTHZ_ALL" userGroupId="ADMIN" artifactGroupId="TUTORIAL"
authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>
If you are required temporary solution for one transition then you can use:
<transition name="createTutorial" read-only="true">
<service-call name="create#tutorial.Tutorial"></service-call>
<default-response url="."/>
</transition>
If you are required a temporary solution but for more transition then you can use:
<always-actions>
<script>ec.artifactExecution.disableAuthz()</script>
</always-actions>
<transition name="createTutorial">
<service-call name="create#tutorial.Tutorial"></service-call>
<default-response url="."/>
</transition>
<transition name="createEmployee">
<service-call name="create#employee.Employee"></service-call>
<default-response url="."/>
</transition>
If you want permanent solution then create below seed data records:
If you want to authrize for availabe UserGroup(ADMIN) then you have to add following seed data:
<moqui.security.ArtifactGroup artifactGroupId="ADMIN_ARTIFACTS" description="Administrators"/>
<!-- for screen path -->
<moqui.security.ArtifactGroupMember artifactGroupId="ADMIN_ARTIFACTS" artifactTypeEnumId="AT_XML_SCREEN" nameIsPattern="N" inheritAuthz="Y" artifactName="component://tutorial/screen/tutorial.xml"/>
<!-- for rest calls -->
<moqui.security.ArtifactGroupMember artifactGroupId="ADMIN_ARTIFACTS" artifactName="/tutorial/fetch-records" artifactTypeEnumId="AT_REST_PATH" nameIsPattern="N" inheritAuthz="Y"/>
<!-- for service path -->
<moqui.security.ArtifactGroupMember artifactGroupId="ADMIN_ARTIFACTS" artifactName="TutorialServices.create#Records" artifactTypeEnumId="AT_SERVICE" nameIsPattern="N" inheritAuthz="Y"/>
<!-- Give authrization to UserGroup: -->
<moqui.security.ArtifactAuthz artifactAuthzId="ADMIN_AUTHZ" userGroupId="ADMIN" artifactGroupId="ADMIN_ARTIFACTS"
authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>
If you want to create your own UserGroupType then you have to add following seed data:
<moqui.basic.Enumeration enumTypeId="UserGroupType" enumId="UgtMyAdmin" description="My Administrators"/>
// If you want to create your own UserGroup then you have to add following seed data:
<moqui.security.UserGroup groupTypeEnumId="UgtMyAdmin" userGroupId="MyAdmin" description="My Administrators"/>
// you can also create artifact group separately:
<moqui.security.ArtifactGroup artifactGroupId="MY_ADMIN_ARTIFACTS" description="My Administrators"/>
// Now you have to give screen permission to your own created UserGroup:
<!-- for screen path -->
<moqui.security.ArtifactGroupMember artifactGroupId="MY_ADMIN_ARTIFACTS" artifactTypeEnumId="AT_XML_SCREEN" nameIsPattern="N" inheritAuthz="Y" artifactName="component://tutorial/screen/tutorial.xml"/>
<!-- for rest calls -->
<moqui.security.ArtifactGroupMember artifactGroupId="MY_ADMIN_ARTIFACTS" artifactName="/tutorial/fetch-records" artifactTypeEnumId="AT_REST_PATH" nameIsPattern="N" inheritAuthz="Y"/>
<!-- for service path -->
<moqui.security.ArtifactGroupMember artifactGroupId="MY_ADMIN_ARTIFACTS" artifactName="TutorialServices.create#Records" artifactTypeEnumId="AT_SERVICE" nameIsPattern="N" inheritAuthz="Y"/>
<!-- Give authrization to UserGroup: -->
<moqui.security.ArtifactAuthz artifactAuthzId="MY_ADMIN_AUTH" userGroupId="MyAdmin" artifactGroupId="MY_ADMIN_ARTIFACTS" authzTypeEnumId="AUTHZT_ALWAYS" authzActionEnumId="AUTHZA_ALL"/>
You can also clone an example component from git:
I hope this will help!
If the transition exist and the user has permission to access it, then all fields disabled is a bug, please report it by create a issue.
I am trying to add file upload to my Spring Webflog form processing. As far as the form enctype is not set to multipart/form-data, form submition works just fine. But after I added enctype="multipart/form-data" to my Spring form, this Exception occurs:
java.lang.IllegalStateException: A flow execution action URL can only be obtained in a RenderRequest or a ResourceRequest
at org.springframework.webflow.context.portlet.PortletExternalContext.getFlowExecutionUrl(PortletExternalContext.java:215)
at org.springframework.webflow.engine.impl.RequestControlContextImpl.getFlowExecutionUrl(RequestControlContextImpl.java:178)
at org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:189)
at org.springframework.webflow.engine.ViewState.render(ViewState.java:293)
at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:242)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:220)
at org.springframework.webflow.engine.Flow.resume(Flow.java:537)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.portlet.FlowHandlerAdapter.handleAction(FlowHandlerAdapter.java:161)
at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:670)
at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:520)
at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:461)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
I have added CommonsMultipartResolver to my spring context:
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- Limit uploads to one byte smaller than the server is allowed to handle -->
<property name="maxUploadSize" value="100000" />
</bean>
and have commons-fileupload.jar in my pom.xml:
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.2.2</version>
</dependency>
My JSP looks like this:
<portlet:actionURL var="processFormAction" >
<portlet:param name="execution" value="${flowExecutionKey}"/>
</portlet:actionURL>
<form:form action="${processFormAction}" modelAttribute="customerModel" enctype="multipart/form-data" method="post" >
<form:input path="firstName" cssClass="input-size-1 valid-required" />
<form:input path="lastName" cssClass="input-size-1 valid-required" />
<input name="avatar" id="avatar" type="file"/>
<input type="submit" name="_eventId_submit" id="send" value="Submit"/>
</form:form>
My flow.xml definition:
<view-state id="state1" model="customerModel">
...
<transition on="submit" to="submitFormActions"/>
</view-state>
<action-state id="submitFormActions">
<evaluate expression="portletAction.processForm(customerModel, flowRequestContext)" />
<transition on="success" to="state2"/>
<transition on="error" to="state1" />
</action-state>
The model object:
public class CustomerModel implements Serializable{
private String firstName;
private String lastName;
private MutlipartFile avatar;
...
//public getters and setters
}
Any thoughts what could be wrong? As I said, without enctype="multipart/form-data" the form processing works well.
Thanks
You are using org.springframework.web.multipart.commons.CommonsMultipartResolver which is not aware about the portlet context.
You need to change CommonsMultipartResolver to:
<bean id="portletMultipartResolver"
class="org.springframework.web.portlet.multipart.CommonsPortletMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes -->
<property name="maxUploadSize" value="100000"/>
</bean>
Also, for this bean to be recognised by DispatcherPortlet, you need to define this bean id as mentioned above. The doc says:
Any configured PortletMultipartResolver bean must have the following id (or name): "portletMultipartResolver".
If you have defined your PortletMultipartResolver with any other name, then the DispatcherPortlet will not
find your PortletMultipartResolver, and consequently no multipart support will be in effect.
I have clientside validation enabled in my config and I'm also including the appropriate jquery files for validation, but every time I submit, the page posts to server without first doing clientside validation. I have pasted the markup generated in the source below. It seems to be generating the data- validation messages fine. Just somehow not triggering validation.
I'm using the BeginCollection library that's available on Nuget to build my dynamic form. Could that be a reason for my clientside validation for somehow not working?
<input class="text-box single-line valid" data-val="true"
data-val-number="The field DaysAbsent must be a number."
data-val-required="The DaysAbsent field is required."
id="students_471abdc8-b190-42da-9f72-ed30a1e33b10__DaysAbsent"
name="students[471abdc8-b190-42da-9f72-ed30a1e33b10].DaysAbsent"
type="text" value="0">
My web.config:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
_Layout.cshtml:
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/jqueryui")
#Scripts.Render("~/bundles/jqueryval")
#RenderSection("scripts", required: false)
BundleConfig.cs:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
You mentioned dynamic form, so if you are loading your inputs dynamically jquery.validate doesn't know they are there. You have to "refresh" your form validations to validate your new inputs.
After adding a new input, use this code to "refresh" the validations for your form:
$('form').removeData('validator');
$('form').removeData('unobtrusiveValidation');
$.validator.unobtrusive.parse($('form'));
I'm using silverlight3 and vb.net..I want to pass the value from Default.aspx to my App or Main page. I wrote the code in my default.aspx page which it is returning the local ip address of the client System, I would like that same address to be used in my silverlight pages.
VB code
Dim clientIPAddress = System.Net.Dns
.GetHostAddresses(strHostName).GetValue(0).ToString()
This clientIPAddress will get the local ip of the client which is like 192.168.1.12. Now i want this value to be passed to my main page.
Please any one help to pass this value from default.aspx to my main page.
Thanks
Your default.aspx page will have an <object> tag where the Silverlight plugin is loaded. You can added a <param name="initParams value="clientID=192.168.1.12"> so it looks something like:-
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/Silverlight3App.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40818.0" />
<param name="autoUpgrade" value="true" />
<param name="initParams` value="clientID=192.168.1.12"`>
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</form>
Except of course you wouldn't hardcode the IP address but you'd inject that with some VB.NET code (I don't do VB.NET).
The initParams parameter is a set of name=value pairs that are exposed in Silverlight as a IDictionary(Of String, String). You can get this dictionary from the Application Startup event arguments or from Application.Current.Host.InitParams.
I am trying to retrieve query string values from a url. And the app should be a silverlight app.
For Eg: The sample URL might look like http://<hostname>/silverlightApp/Default.aspx?S=Name|address|title|sal|...
I should be able to take the query string and built a Silverlight UI.
Can this be done or Silverlight is not a good candidate for this type.
There are multiple ways you can do this. In the hosting page, you can pull out query string values using Request.QueryString, and then pass them to Silverlight using the initParams tag, i.e.:
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
width="100%" height="100%">
<param name="source" value="/ClientBin/MyApplication.xap" />
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40620.0" />
<param name="autoUpgrade" value="true" />
<param name="windowless" value="true" />
<param name="initParams" value="<%=InitParameters %>" />
<param name="splashScreenSource" value="<%=SplashScreenSource %>" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40620.0" style="text-decoration: none;">
<img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight"
style="border-style: none" />
</a>
</object>
Or from within the Silverlight application itself, you can grab the querystring and other parts of the URI by using HtmlPage.Document.documentUri, e.g.:
Uri uri = HtmlPage.Document.DocumentUri;
And once you've got the actual querystring, you can parse it using regular expressions, or whatever your poison of choice happens to be.
HTH.
See System.Web.HttpUtility.ParseQueryString() Method, which parses a query string into a NameValueCollection.
[Later] Sorry, the Silverlight runtime seems to be without the System.Web namespace.
See system.Uri.Query in the System namespace provided with Silverlight runtime.
The Query property contains any query information included in the URI. Query information is separated from the path information by a question mark (?) and continues to the end of the URI. The query information returned includes the leading question mark.
The query information is escaped according to RFC 3986.
The following example writes the query ?date= today to the console.
Uri baseUri = new Uri ("http://www.contoso.com/");
Uri myUri = new Uri (baseUri, "catalog/shownew.htm?date=today");
outputBlock.Text += "Uri.Query: ";
outputBlock.Text += myUri.Query;
outputBlock.Text += "\n";