This is my java code
public class TestClient
{
public int a=55;
public void setname(String nameeey){
}
public int foo(){
return 55;
}
public String foo2(int value, int a2,double hool){
return "2343";
}
}
and this is the porttype of the wsdl doc
<wsdl:portType name="TestClientPortType">
<wsdl:operation name="foo">
<wsdl:input name="foo" message="tns:foo">
</wsdl:input>
<wsdl:output name="fooResponse" message="tns:fooResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="setname">
<wsdl:input name="setname" message="tns:setname">
</wsdl:input>
<wsdl:output name="setnameResponse" message="tns:setnameResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="foo2">
<wsdl:input name="foo2" message="tns:foo2">
</wsdl:input>
<wsdl:output name="foo2Response" message="tns:foo2Response">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
what does
<wsdl:output name="fooResponse" message="tns:fooResponse">
mean?
Web Services relate to messaging and their are various Message Exchange Patterns (MEPs). In the case of the foo operation, it is an IN-OUT pattern, or request/response (relating to the java method).
The input message is the request you are sending to the service and the output message is the response from the service. So the 'fooResponse' message is a wrapper around the integer return value.
Check out these
http://www.w3schools.com/wsdl/wsdl_documents.asp
http://www.w3schools.com/wsdl/wsdl_ports.asp
Related
I'm completely new to MVC. I following a tutorial where you are supposed to connect to a database and pull data from a table. Unfortunately This is not working. I'm supposed to be able to add "/Employee/Details/1" to the address bar after "localhost:12345" and get the values located in the first row of the table. I'm not sure what code to post so I will post what I think is relevant and a copy of the error details. Please let me know if I need to post more code in order to get more help. Thanks!
EmployeeController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcDemo2.Models;
namespace MvcDemo2.Controllers
{
public class EmployeeController : Controller
{
//
// GET: /Employee/
public ActionResult Details(int id)
{
EmployeeContext employeeContext = new EmployeeContext();
Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeId == id); //THIS IS THE LINE HIGHLIGHTED AS PART OF THE ERROR
return View(employee);
}
}
}
<-------next file-------->
Employee.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace MvcDemo2.Models
{
[Table("dbo.Employees")]
public class Employee
{
[Key]
public int EmployeeId { get; set; }
public string Name { get; set; }
public string Gender { get; set; }
public string City { get; set; }
}
}
<-------next file-------->
EmployeeContext.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
namespace MvcDemo2.Models
{
public class EmployeeContext : DbContext
{
public DbSet<Employee> Employees { get; set; }
}
}
<-------next file-------->
Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="EmployeeContext"
connectionString="server=MISSIONCNTRL-PC\SQLEXPRESS; database=Sample; integrated security=SSPI"
providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
<-------next file-------->
Global.asax.cs
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
namespace MvcDemo2
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
Database.SetInitializer<MvcDemo2.Models.EmployeeContext>(null);
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
}
<-----Error Message----->
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=Sequence contains no elements
Source=System.Core
StackTrace:
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__3[TResult](IEnumerable`1 sequence)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.Single[TSource](IQueryable`1 source, Expression`1 predicate)
at MvcDemo2.Controllers.EmployeeController.Details(Int32 id) in d:\Visual Studio 2012\Projects\MvcDemo2\MvcDemo2\Controllers\EmployeeController.cs:line 18
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41()
at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()
FYI. I have read through the other threads that are using the same tutorial and have tried their code but I still have no luck. Could really use some help on this one. It important to me to try to figure this out.
Try this
public ActionResult Details(int id)
{
EmployeeContext employeeContext = new EmployeeContext();
Employee employee = employeeContext.Employees.Find(id);
if (employee != null)
return View(employee);
return new HttpStatusCodeResult(HttpStatusCode.NotFound);
}
#model MvcDemo2.Models.Employee
#{
ViewBag.Title = "Details";
}
<h2>Employee Details</h2>
<table style="font-family: Arial">
<tr>
<td>
<b>Employee Id:</b>
</td>
<td>
#Model.EmployeeId //this is where the error is
</td>
</tr>
<tr>
<td>
<b>Name:</b>
</td>
<td>
#Model.Name
</td>
</tr>
<tr>
<td>
<b>Gender:</b>
</td>
<td>
#Model.Gender
</td>
</tr>
<tr>
<td>
<b>City:</b>
</td>
<td>
#Model.City
</td>
</tr>
</table>
<--------ERROR Message-------->
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=App_Web_qs2w0l3a
StackTrace:
at ASP._Page_Views_Employee_Details_cshtml.Execute() in d:\Visual Studio 2012\Projects\MvcDemo2\MvcDemo2\Views\Employee\Details.cshtml:line 14
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
InnerException:
Thankyou dasu908 for the help. I'm really getting frustraited with this.
I have set up a usercontrol with a rotating animation.
Inside my storyboard, I have a value, that determines, whether the control rotates to the left (-360.0) or to the right (360.0). The value inside the XAML Storyboad looks like this:
<EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="-360.0"/>
In the code behind, I wrote a DependencyProperty, where you can set a value (360 or -360). That looks like this:
public static double GetRotationValue(DependencyObject obj)
{
return (double)obj.GetValue(RotationValueProperty);
}
public static void SetRotationValue(DependencyObject obj, double value)
{
obj.SetValue(RotationValueProperty, value);
}
public static readonly DependencyProperty RotationValueProperty= DependencyProperty.RegisterAttached("RotationValue", typeof(double), typeof(RotatingWheel.MainControl), new PropertyMetadata(360.0));
Now, I want to use this DependencyProperty as the source of the value. I tried the following:
<EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="{Binding RelativeSource={RelativeSource Self}, Path=RotationValue}"/>
That does not work. I looked into other cases and found, that you must set the correct data context for the control to "self". So I added in the XAML of the user control:
DataContext="{Binding RelativeSource={RelativeSource Self}}"
So my question is: How can I bind a value to a DependencyProperty, that lives inside the same control?
------------------------------------------------------
Here ist the complete XAML Code:
<UserControl
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc ="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ed ="http://schemas.microsoft.com/expression/2010/drawing"
DataContext="{Binding RelativeSource={RelativeSource Self}}"
x:Name="RotatingWheel"
mc:Ignorable="d"
x:Class="RotatingWheel.MainControl"
xmlns:rw="clr-namespace:RotatingWheel"
d:DesignWidth="640" d:DesignHeight="480" Width="100" Height="100">
<UserControl.Resources>
<Storyboard x:Name="Storyboard">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="rectangle" RepeatBehavior="Forever">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<!--I want to bind this value to RotationValue DependencyProperty-->
<EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="{Binding RelativeSource={RelativeSource Self}, Path=RotationValue}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="rectangle1" RepeatBehavior="Forever">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="-360.0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<ed:Arc ArcThickness="20" ArcThicknessUnit="Pixel" EndAngle="360" Fill="Gray" HorizontalAlignment="Left" Height="100" Margin="0" Stretch="None" Stroke="White" StartAngle="0" UseLayoutRounding="False" VerticalAlignment="Top" Width="100"/>
<Rectangle x:Name="rectangle" Fill="White" HorizontalAlignment="Left" Height="20" Margin="0,40,0,0" Stroke="White" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<CompositeTransform/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle x:Name="rectangle1" Fill="White" HorizontalAlignment="Left" Height="100" Margin="40,0,0,0" Stroke="White" VerticalAlignment="Top" Width="20" RenderTransformOrigin="0.5,0.5">
<Rectangle.RenderTransform>
<CompositeTransform/>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</UserControl>
------------------------------------------------------
Here is the complete code behind file:
using System.Windows;
using System.Windows.Controls;
namespace RotatingWheel
{
public partial class MainControl : UserControl
{
public MainControl()
{
// Für das Initialisieren der Variablen erforderlich
InitializeComponent();
this.Loaded += new System.Windows.RoutedEventHandler(MainPage_Loaded);
}
private void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
this.Storyboard.Begin();
}
#region DP RotationValue (360 or -360)
public static double GetRotationValue(DependencyObject obj)
{
return (double)obj.GetValue(RotationValueProperty);
}
public static void SetRotationValue(DependencyObject obj, double value)
{
obj.SetValue(RotationValueProperty, value);
}
public static readonly DependencyProperty RotationValueProperty = DependencyProperty.RegisterAttached("RotationValue", typeof(double), typeof(RotatingWheel.MainControl), new PropertyMetadata(360.0));
#endregion
}
}
I am very sorry. The correct answer is very plain and easy:
This works:
<EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="{Binding RotationValue}"/>
This doesn't work:
<EasingDoubleKeyFrame KeyTime="0:0:0.75" Value="{Binding RelativeSource={RelativeSource Self}, Path=RotationValue}"/>
Setting the DataContext was correct:
DataContext="{Binding RelativeSource={RelativeSource Self}}"
the three files are given for struts2.it is not giving the output.its giving
jasper exception.please find the errors
========================
updatedesig.jsp
=======================
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#taglib prefix="p" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<p:form action="count"method="post">
<p:select name="country" list="countryList" label="Select a country" />/*creating list in jsp*/
</p:form>
<h1>Hello World!</h1>
</body>
</html>
========================
struts.xml
========================
<struts>
<package name="b" extends="struts-default">
<action name="count" class="b.Countr" >/*action class is Countr.java*/
<result name="success">updatedesig.jsp</result>
</action>
</package>
</struts>
============================
Countr.java
============================
package b;
import java.util.ArrayList;
import com.opensymphony.xwork2.ActionSupport;
public class Countr extends ActionSupport/*class Countr*/
{
public ArrayList countrylist;
String country;
public ArrayList getCountrylist()/*getting countrylist*/
{
return countrylist;
}
public void setCountrylist( ArrayList countrylist)/*setting countrylist*/
{
this.countrylist=countrylist;
}
public String getCountry()/*getting country*/
{
return country;
}
public void setCountry( String country)/*setting country*/
{
this.country=country;
}
public String execute()
{
countrylist = new ArrayList();/*creating the arraylist*/
countrylist.add("1");
countrylist.add("!");
countrylist.add("1");
return SUCCESS;
}
}
/*some parts of Glassfish server log */
WARNING: StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
tag 'select', field 'list', name 'country': The requested list key 'countryList' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]
at org.apache.struts2.components.Component.fieldError(Component.java:237)
at org.apache.struts2.components.Component.findValue(Component.java:358)
at org.apache.struts2.components.ListUIBean.evaluateExtraParams(ListUIBean.java:80)
at org.apache.struts2.components.Select.evaluateExtraParams(Select.java:105)
at org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:856)
at org.apache.struts2.components.UIBean.end(UIBean.java:510)
at org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:42)
at org.apache.jsp.updatedesig_jsp._jspx_meth_p_select_0(updatedesig_jsp.java:138)
at org.apache.jsp.updatedesig_jsp._jspx_meth_p_form_0(updatedesig_jsp.java:107)
at org.apache.jsp.updatedesig_jsp._jspService(updatedesig_jsp.java:68)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
its always better to provide the error/exception being thrown by the system else its very hard for the other to tell anything.Moreover no one have that much time to write the programe in there system and see the error.
my first shot for possible error is
<p:select name="country" list="countryList" label="Select a country" />
which means it will try to find the respected getter method getCountryList() in your action class but your action class have the following method
public ArrayList getCountrylist()/*getting countrylist*/
{
return countrylist;
}
either change the select to
<p:select name="country" list="countrylist" label="Select a country" />
or do the required correction in your action class.
Its always advisable to program to interface rather than implementation which will provide you more flexibility.
You can create List and initialize it with ArrayList.Here is what is working for me
Action Class
List<String> countryList;
public List<String> getCountryList() {
return countryList;
}
public void setCountryList(List<String> countryList) {
this.countryList = countryList;
}
countryList=new ArrayList<String>();
countryList.add("1");
countryList.add("!");
countryList.add("1");
JSP Class
<s:select name="country" list="countryList" label="Select a country" />
OutPut
I'm trying to display a list of images embedded in my asssembly in a ListBox. I can get the images to display using a converter, but rather than loading, then staying still, they constantly reload from the assembly causing them to flicker. I'm using the same Converter to load the icons in various other places around my app but this problem does not occur- it seems to be cause by the lisbox somehow. I've tried removing the VisualStates and switching the CreateOption for the Bitmap image which the converter returns, but I get the same result. I'm fairly sure this didn't happen on WP7.0, only 7.1.
The style is:
<Style x:Key="SnapshotList" TargetType="ListBox">
<Setter Property="Margin" Value="2" />
<Setter Property="BorderThickness" Value="1"/>
<!--<Setter Property="Background" Value="{StaticResource WindowBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource PhoneBorderBrush}" />-->
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<!--Setter Property="OverridesDefaultStyle" Value="True"/-->
<Setter Property="ItemTemplate" Value="{StaticResource SnapshotTemplate}"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<Controls:WrapPanel HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
<!--<WP7:BindingHelper.Binding>
<WP7:RelativeSourceBinding Path="(FrameworkElement.ActualWidth)" TargetProperty="Width"
RelativeMode="FindAncestor"
AncestorType="ScrollContentPresenter" />
</WP7:BindingHelper.Binding>-->
<!--</Controls:WrapPanel>-->
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBox">
<Border Name="Border" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}"
BorderBrush="{StaticResource PhoneBorderBrush}" CornerRadius="2">
<ScrollViewer Margin="0">
<ItemsPresenter/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
The listbox in question:
<ListBox x:Name="lstIcon" ItemsSource="{Binding AvailableIcons}" SelectedItem="{Binding Recipe.Icon,Mode=TwoWay}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SelectionMode="Single"
Style="{StaticResource SnapshotList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Border Background="Transparent" MinWidth="30" MinHeight="30" Margin="3" Padding="3">
<Image Source="{Binding Converter={StaticResource IconConverter}, ConverterParameter=32}" Stretch="None" MinWidth="30" MinHeight="30" />
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
The converter:
public class IconConverter : IValueConverter
{
private static IEnumerable<string> _names;
private static IEnumerable<string> ResourceNames {
get {
if (_names == null) {
_names = WP7Utils.GetResourcePaths(Assembly.GetExecutingAssembly()).Select(p=>System.Convert.ToString(p)).ToList();
}
return _names;
}
}
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
string baseFilename = (value ?? Shared.Constants.DefaultIcon).ToString().Trim();
string size = (parameter ?? "32").ToString();
try {
BitmapImage img = new BitmapImage();
using (var store = IsolatedStorageFile.GetUserStoreForApplication()) {
string fileName = string.Format("{0}_{1}.png", baseFilename, size);
img = ResourceHelper.GetBitmap("Resources/types/" + fileName, "MyAssembly");
}
return img;
} catch (Exception ex) {
Console.WriteLine(string.Format("Error loading image {0} ({1}px): {2}", baseFilename, size, ex.Message));
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
throw new NotImplementedException();
}
}
This was caused by specifying the MinHeight and MinWidth in the DataTemplate for the ListBox. Removing the attributes fixed the problem.
You should also set the caching on the caching on the image to BitmpaCache to prevent the need for the framework to need to reload/redraw the image.
I would like to include the value of a scalar function as a read-only property of an entity, since that I could include that value in a filter, is such a thing possible?
The solution is to add a DefiningQuery like in the following sample:
<!-- SSDL content -->
<EntitySet Name="Emp" EntityType="TestModel.Store.Emp" >
<DefiningQuery>
SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, dbo.MyFunc(DEPTNO) AS DNAME FROM EMP
</DefiningQuery>
</EntitySet>
<EntityType Name="Emp">
<Key>
<PropertyRef Name="EMPNO" />
</Key>
<Property Name="EMPNO" Type="int" Nullable="false" />
...
<Property Name="DNAME" Type="varchar" MaxLength ="20" />
</EntityType>
...
<!-- CSDL content -->
...
<EntityType Name="Emp">
<Key>
<PropertyRef Name="EMPNO" />
</Key>
<Property Name="EMPNO" Type="Int32" Nullable="false" />
...
<Property Name="DNAME" Type="String" MaxLength="20" Unicode="false" FixedLength="false" />
</EntityType>
<!-- C-S mapping content -->
...
<ScalarProperty Name="EMPNO" ColumnName="EMPNO" />
...
<ScalarProperty Name="DNAME" ColumnName="DNAME" />
...
The usage example:
using(TestEntities4 db = new TestEntities4()) {
var q = from e in db.Emp where e.DNAME == "RESEARCH" select e;
}
In EF4 you can define a partial class of the same name as your Entity Framework class in the same namespace and add read-only properties to that. I've just done that to expose the description of a connected Entity object as a read-only property of the original object.
namespace same.as.the.data.model
{
public partial class Order
{
public string CustomerName
{
get { return Customer.Name; }
}
}
}