Passing value from Default.aspx to App or Main page in silverlight3 - vb.net

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.

Related

Spring Webflow - IllegalStateException when using multipart/form-data and file upload

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.

asp.net mvc4 clientside validation doesn't work

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 can't submit a form with Dojo DateTextBox

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"

SWF behaves strangely when it is embeded in HTML

I have a SWF file and I am trying to embed it into an HTML.
I used the following code:
<object width="704" height="440">
<param name="movie" value="http://riskgames.ist.psu.edu/CyberLinkIT.swf"></param>
<embed src="http://riskgames.ist.psu.edu/CyberLinkIT.swf" type="application/x-shockwave-flash" menu="false" width="704" height="440">
</embed>
</object>
If you go to http://miaojiang.net/bug.html, you can see the problem. The button is blinking and all invisible text field are displayed.
However, if I open the swf file directly, there is no problem.
Any idea?
This is your problem.
SecurityError: Error #2149: Security sandbox violation: https://riskgames.ist.psu.edu/CyberLinkIT.swf cannot make fscommand calls to http://miaojiang.net/bug.html (allowScriptAccess is ).
at FSCommand$/_fscommand()
at global/flash.system::fscommand()
at CyberLinkIT_fla::MainTimeline/frame1()
<object width="704" height="440">
<param name="movie" value="http://riskgames.ist.psu.edu/CyberLinkIT.swf"></param>
<param name="AllowScriptAccess" value="always"></param>
<embed src="http://riskgames.ist.psu.edu/CyberLinkIT.swf" type="application/x-shockwave-flash" menu="false" width="704" height="440" AllowScriptAccess="always">
</embed>
</object>

Collecting Query string values from URL in Silverlight and WCF application

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";