w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Better way of writing these Guice Multibind statements?
You could extend the DSL a little. mySpecialBinding("Name1", SubClass1.class); mySpecialBinding("Name2", SubClass2.class); // ... void mySpecialBinding(String name, Class<? extends SuperClass> clazz) { bind(SuperClass.class).annotatedWith(Names.named(name)) .to(clazz).in(Scopes.SINGLETON); multiBinder.addBinding().to(clazz) .in(Scopes.SINGLETON); }

Categories : Java

Complex Spring Converter with Converter inside?
With class BB like: class BB { .... AA aa; .... } You can simply do: public BB convert(B b) { BB bb = new BB(); bb.aa = new AToAAConverter().convert(b.a); .... You can still register your AToAAConverter in ConversionServiceFactoryBean.

Categories : Spring

Htm to pdf converter with css
When I have dealt with this in the past on secure servers, I have had to change the css reference before passing to the pdf converter. Had similar problems with image references. If the reference is to a secure server, the converter can't see it, and if it points to non-secure server, the secure page nags the user about unsecure content.

Categories : Asp Net

WPF YesNo Converter
Your conversion is backwards, because the binding source (LicensedBitDisplay) contains strings. Convert converts from source to target. Source is the ViewModel, target is the UI control binding to it). ConvertBack converts from target to source. This is generally only useful when you have a control accepting user input (e.g. user types "Yes" in a textbox and the converter gives 1 to the ViewModel property). To make this work, LicensedBitDisplay should be a collection of int?. Also, your current implementation of Convert will fail because int? can't be cast to bool. Instead you can use System.Convert.ToBoolean (which will also convert null to false automatically). The converter should be used for display only, in the ComboBox's ItemTemplate: <ComboBox ItemsSource="{Binding Path=Licens

Categories : C#

DWR converter for String
DWR documentation (http://directwebremoting.org/dwr/documentation/server/configuration/dwrxml/converters/index.html) states that : "The converters for primitives, strings and simple objects like BigDecimal are all there waiting for you. You don't need a element in the section in dwr.xml to use them - They are enabled by default. The types enabled by default include: boolean, byte, short, int, long, float, double, char, java.lang.Boolean, java.lang.Byte, java.lang.Short, java.lang.Integer, java.lang.Long, java.lang.Float, java.lang.Double, java.lang.Character, java.math.BigInteger, java.math.BigDecimal, java.util.Collection (implemenations), java.util.Map (implemenations), java.lang.String, etc. For a complete list you can take a look at the dwr.xml which defines

Categories : Misc

Html to pdf converter
You may try this after Response.Write(pdfDoc); Response.Write(pdfDoc); FileStream fs = new FileStream(Server.MapPath("~/pdfFolder/pdfFile.pdf"), FileMode.Create); StreamReader sr = new StreamReader(Response.OutputStream); byte[] data = new byte[Response.OutputStream.Length]; Response.OutputStream.Read(data, 0, data.Length); fs.Write(data, 0, data.Length); fs.Flush(); fs.Close(); Other than this the third party tool you are using or PDF generation may too be providing you features for this operation.

Categories : Asp Net

datetime converter WPF
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value is DateTime) { string date=value.Date.ToShortDateString(); return (date); } return string.Empty; }

Categories : C#

Date Converter using WPF
You dont need a converter for doing this. You can use the StringFormat in binding itself to format your selected datetime to show just date in mm/dd/yyyy format. <TextBlock Text="{Binding Date, StringFormat={}{0:MM/dd/yyyy}}" /> I tested with this code and it is working fine. XAML: <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding TestList}"> <DataGrid.Columns> <DataGridTemplateColumn Header="Start"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Start, StringFormat=d}" FontFamily="Verdana" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellEdi

Categories : C#

Hex Converter ArgumentOutOfRangeException
I am not sure what you want your method to return if it doesn´t receive a valid hexadecimal number but you might want to test your string if it is a valid hex number with the following regular expression: Regex.IsMatch(test, @"A[0-9a-fA-F]+"); Although, I would suggest that you leave it as it is and let your method throw an exception if the argument is wrong. You should have error handling on a higher level to recover from this.

Categories : C#

Converter ID to object
Where is your 'HGERP.Data.ArbeitsplatzGruppe' class defined? If it is in another dll or project you will need to reference that specific dll or project from your mvc project. You can right click the references section to add an assembly reference.

Categories : C#

WPF Converter Error
The error says The name "WidthConverter" does not exist in the namespace "clr-namespace:WPF_NewProject.converters". The first line of your converter says Namespace converters Either change your declared namespace to WPF_NewProject.converters or change your XML namespace declaration to xmlns:local="clr-namespace:converters"

Categories : Wpf

WPF Converter Property
My BoolToVisibilityConverter is below. You can either use it as a resource: <converters:BoolToVisibilityConverter x:Key="FalseToHidden" TrueValue="Visible" FalseValue="Hidden" /> or use it as a MarkupExtension inline in your XAML: Visibility="{Binding MyFlag, Converter={vc:BoolToVisibilityConverter FalseValue=Collapsed, TrueValue=Visible}}" C# public class BoolToVisibilityConverter : BoolToValueConverter<Visibility> { #region Constructors and Destructors public BoolToVisibilityConverter() { this.TrueValue = Visibility.Visible; this.FalseValue = Visibility.Collapsed; } #endregion } /// <summary> /// Use as the base class for BoolToXXX style converters /// </summary> /// <typeparam nam

Categories : Wpf

C# decoding ( converter)
If you're asking "Q: How do I parse a hex string in C#?" , the answer is: int.Parse(hexValue, System.Globalization.NumberStyles.HexNumber); http://msdn.microsoft.com/en-us/library/system.globalization.numberstyles.aspx http://msdn.microsoft.com/en-us/library/bb311038.aspx

Categories : C#

currency converter help c#
You never return the values back to your main program private static double exhangeNumber() private static double wholeNumber() At the bottom of these instead of using console readline use, return ivalue/evalue; respectively. Then in main you can do Console.WriteLine(exchangeNumber() * wholeNumber()); Console.ReadLine(); As Steve said in the comments, you may wish to use TryParse instead of Parse to get the values as it will give you extra error handling and will give the default value if your user's input isn't a valid number, for a double this is 0.0.. As well as this, TryParse will also return a boolean as to whether or not the parsing was successful For example: evalue = double.Parse(Console.ReadLine()); is the same as (but improved) double.TryParse(Console.ReadLine(),

Categories : C#

Why converter is not getting called
In first example: It's not working because you don't assign DataContext so it's equal to null. You can fix it by assign to DataContext value: public partial class MainWindow : Window { public Model Model { get; set; } public MainWindow() { Model=new Model(); InitializeComponent(); this.DataContext = this; } } And now below binding will be working: <ListView ItemsSource="{Binding Model,Converter={StaticResource PropConverter}}"/> The better option is learning MVVM pattern and assign to DataContext ViewModel: public class MainViewModel { public MainViewModel() { Model = new Model(); } public Model Model { get; set; } } View: public partial class MainWindow : W

Categories : C#

Base class for JPA converter
In DataNucleus there's a bug for this. I filled in a bug report http://datanucleus.org/servlet/jira/browse/NUCACCESS-117. Please follow up there to check in which release will be included.

Categories : Java

Flash to html5 converter
You best choice is Tools For Create JS. It's a Flash Professional plugin that allows you to publish flash content to HTML5. Link: http://www.adobe.com/products/flash/flash-to-html5.html Also, take a look at the tutorial by Lee Brimelow: http://gotoandlearn.com/play.php?id=174 --- Flash Toolkit for CreateJS and http://gotoandlearn.com/play.php?id=172 --- Converting ActionScript to JavaScript As you will see you can do some amazing stuff using Flash Professional just to make a design/art but you'll also see that you'll have to do some coding as well, so it's not a perfect solution. If you're interested in creating games/applications that will run in Flash (.swf), JavaScript (.html, .js) and most other popular platform, your best bet is to look into Haxe (http://haxe.org). Moreover it'

Categories : HTML

currency converter virtuemart
The following relates to Virtuemart2. In most cases you would simply convert to the default shop currency and just let Virtuemart handle it from there. Virtuemart will convert and display shop currencies as per the users selected currency. Do so as follows: If you know the currency_code ... $amount_in_shop_currency = convertToShopCurrency($amount_in_AUD, 'AUD'); function convertToShopCurrency($amount, $currency_code) { if (!$currency_code) return $amount; $dbo = JFactory::getDBO(); $dbo->setQuery("SELECT virtuemart_currency_id FROM #__virtuemart_currencies WHERE currency_code_3 = '{$currency_code}' LIMIT 1"); $currency_id = $dbo->loadResult(); if (!$currency_id) return

Categories : PHP

Javascript: Currency converter
To fix your JS do the following: The issue is that your switch would compute to a single string, and you are using fall-through switch statements, jsFiddle to demonstrate what I mean. Switch Statement Documentation for JavaScript function calculation() { var amount = document.getElementById('amount').value; var currency1 = document.getElementById('select1').value; var currency2 = document.getElementById('select2').value; switch (currency1 + ' ' + currency2) { case "pound pound": var y = amount * 1; document.getElementById('result').innerHTML = "&pound; " + parseFloat(Math.round(y * 100) / 100).toFixed(2); break case "pound real": var x = currency2 = 3.40; var y = amount * x; doc

Categories : Javascript

WPF string to double converter
You do not need a converter for this, use the .ToString() method at the property. public string GraphPenWidthValue { get { return this.GraphPenWidth.ToString(); } } Anyway here is a Standart String Value Converter: [ValueConversion(typeof(object), typeof(string))] public class StringConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return value == null ? null : value.ToString(); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } }

Categories : C#

Spring Web Flow Converter
You can do atleast adding binding null value or empty string to your model. So you can use default value for select one menu. Like this: <sf:option value="">Please select...</sf:option> But in your Formatter or Converter, you should check your model property is null or empty String and if so return null or empty String as you like. Like this: public YourEnum parse(String value, Locale local) throws ParseException { if(YourEnum.valueOf(YourEnum.class, value.toUpperCase()) == YourEnum.VALUEONE) { return YourEnum.VALUEONE; } else if(YourEnum.valueOf(YourEnum.class, value.toUpperCase()) == YourEnum.VALUETWO) { return YourEnum.VALUETWO; } else { return null; } }

Categories : Java

Deserialize json with converter
Given the object you want to convert, you can use the ToObject<T>() to get the converted object. In your case, you want to convert the second item in the array to a MetaData object. public class DeltaEntryConverter : JsonConverter { public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var arr = (JArray)serializer.Deserialize(reader); return new DeltaEntry { Path = (string)arr[0], MetaData = arr[1].ToObject<MetaData>(), }; } public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { throw new NotImplementedException(); } public override bool CanConvert(Type objectType) { thr

Categories : Dotnet

Python Temperature Converter
You are not returning a value. Also you are not storing all the computed values back into the variable x def F_C(x): x = raw_input("Please Enter A Value") x = int(x) x = x - 32 x = x * 0.55 return x You can simplify it to: def F_C(): x = raw_input("Please Enter A Value") return (int(x) - 32)*0.55

Categories : Python

Converter for entity in h:outputText
When you have a converter with a forClass it gets called if the value is of the specified type. myBean.myType is obviously of type MyType but (#{myBean.myType}) which evaluates to #{'('.concat(myBean.myType.toString()).concat(')') is of type String, so the converter will not and can not be applied on the given value. I think your intention was, that the converter will be used whenever a EL expression evaluates to a value of type MyType. But it will only be applied as if you would specify it by <f:converter converterId="myTypeConverter"/> on some ui-controls. This would not work either if the given value-property is of an invalid type. To resolve this you would either have to override the toString-method on MyType, to call the converter explicitly in the EL or to define another meth

Categories : JSF

greasemonkey currency converter
You need to recurse or loop through just the nodes that have the dollar values. Never use replace() or RegExp on .html() or innerHTML. Not only will this trash the target page, but you will have a devil of a time getting the desired results. Recurse through the page using DOM methods. Note that currency values come in many formats, so converting them can get complex. Here's moderately robust code for the whole page (sans iframes) You can see it in action at jsFiddle: // ==UserScript== // @name _Global currency converter, dollars to rupees // @include http://YOUR_SERVER.COM/YOUR_PATH/* // @grant GM_xmlhttpRequest // ==/UserScript== GM_xmlhttpRequest ( { method: "GET", url: 'http://rate-exchange.appspot.com/currency?from=USD&to=INR', //Google sends m

Categories : Javascript

converter between different Java types
Adapter is the desgin pattern http://en.wikipedia.org/wiki/Adapter_design_pattern for converting one type to another. Creating new objects from other objects would be "prototype". Or simply creating new instances uses a "factory" or a "builder".

Categories : Java

JSF Converter for non-persisted entity
You could use OmniFaces SelectItemsConverter for this. It converts the submitted value directly based on the available values in <f:selectItems> by default via object's toString() representation. So if you can guarantee that you can provide an unique toString() representation, then this converter should just do it. Additional bonus is that this converter don't hit the DB at all. After dropping OmniFaces JAR in the webapp's runtime classpath, it's just a matter of <h:selectOneMenu ... converter="omnifaces.SelectItemsConverter"> without any additional configuration or code. See also the showcase example.

Categories : JSF

selectonemenu jsf on objects with converter
I have the solution. I had to override the "equals" method in MyObject class! Thanks. EDIT: the code @Override public boolean equals(Object obj) { if(this.id == ((MyObject) obj).id) { return true; }else { return false; } }

Categories : JSF

Javascript Unit Converter
Try and make two different javascript functions AnyUnitToDecimalConverter() Function DecimalToAnyUnitConverter() Function Now suppose you need to convert from X unit to Y unit: Call AnyUnitToDecimalConverter(valueX), this will give you a decimal answer say AnsDecimal and now Call DecimalToAnyUnitConverter(AnsDecimal);

Categories : Javascript

AT&T to Intel assembly converter
There's a not-quite-complete Perl script here that might help you out if you're up for making some modifications/extensions to anything missing: http://boinc.berkeley.edu/android-boinc/libssl/crypto/perlasm/x86_64-xlate.pl If not, just run Att2Intl in DOSBox or a WinXP VM. If you don't have access to XP, you could also try installing ReactOS in a VM. I believe they used DOSBox source to implement the DOS layer so that may provide a long-term solution without having to resort to actually running DOSBox every time.

Categories : Assembly

JSF 2 , noSelectionOption with Converter , Not working as it should
The above issue was due to a4j:commandlink which was having reRender attribute , i replaced it with render attribute and now message is getting displayed. But now the issue is *if required=true is not there and i select noSelectionOption then it will store blank value in DB. is it necessary to provide a validator in jsf 2 for noSelectionOption ???? Thanks

Categories : JSF

Bool to Visibility Converter in WPF
Change the Visibility binding to: <GroupBox Grid.Row="7" Grid.Column="1" Visibility="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}} Path=DataContext.IsMonthlyInterestChecked, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource VisibilityConverter}}" > Then add a property IsMonthlyInterestChecked to your ViewModel and bind RadioButton to it: <RadioButton Grid.Column="0" x:Name="rdbMonthlyInterest" Content="Monthly Interest" Style="{StaticResource RadioButtonWhite}" IsChecked="{Binding IsMonthlyInterestChecked}"/>

Categories : C#

Puppet to chef converter
So, I do not believe there is a 'simple script' way available yet to do this conversion. What I've done in testing is to use Blueprint to do the following: Install a fresh node with Puppet for the node type you wish to "convert". Allow Blueprint to scan the resulting server. Use Blueprint to export either Chef or Puppet code. Repeat for each node type you have defined in Puppet (or Chef, if you go the other direction). From the Blueprint README.md: Blueprint reverse-engineers servers. Easy configuration management. Detect relevant packages, files, and source installs. Generate reusable server configs. Convert blueprints to Puppet or Chef or CFEngine 3. No DSLs, no extra servers, no workflow changes. I hope I'm proven wrong, and there is a soup-to-nuts script to just "convert" from

Categories : Misc

Speech to text converter in .net
There is best article provided for converting speech to text. Please refer http://ellismis.com/2012/03/17/converting-or-transcribing-audio-to-text-using-c-and-net-system-speech/ Hope this helps you.

Categories : C#

why does the converter not receive a value while binding
I generally do a sanity check in my converters, and if the value is null, return Binding.DoNothing. Sometimes your converter will get a null value. The key is to not throw an exception.

Categories : C#

Converter to only run when textblock is updated
The Converter is only run when the Binding thinks there is a new value to bind. I'm guessing one of these situations occur when you click "Save": 1: Your code resets the item's Start property: item.Start = updatedDate; *) That is the same as @nit's suggestion, which you already checked. 2: In your collection of items, you replace the item that was just saved: myList.Remove(oldItem); myList.Add(updatedItem); 3: You replace the whole list of items that is bound to the DataGrid; myGrid.ItemsSource = updatedList;

Categories : C#

JSF entity converter dificulty
Solved it! I implemented search method inside restaurant managed bean(i also have it inside merchant managed bean, and i was trying to use it); info is stored in one instance of a Merchant and when i'm manipulating an instance of a Restaurant, before persisting changes i set this Restaurant's merchant (Foreign Key). Below relevant code on my restaurant managed bean. //the merchant to store values searched, used in update private Merchant searchedMerchant; private String searchValue; //the correspondent restaurant-merchant, used in update, and new record private Merchant merchant; /** * @return the merchant */ public Merchant getMerchant() { return merchant; } /** * @param merchant the merchant to set */ public void setMerchant(Merchant merchant) { this.merchant = merchant; }

Categories : JSF

VMware Converter Automation
VMware vCenter Converter has its own SOAP/WebServices based API. SDK can be found at https://www.vmware.com/support/developer/converter-sdk/ So you can automate any task basically, using a programming language which is capable to work with WebServices

Categories : Powershell

JSF selectManyCheckbox converter to String
The JSF converter is applied repeatedly on every individual item, not once on the whole collection/array as you seemd to expect. So, no, that's not possible. If you absolutely need to malform the model like this, just perform the conversion job afterwards in the business layer. (if I guess right what you're actually trying to do, storing multiple values commaseparated in a single DB column; start reading about DB normalization, foreign key relationships and JOINs)

Categories : Java

String-Object converter
You can for example use Jackson to convert object to JSON and vice versa. Check this article How To Convert Java Object To / From JSON If you want, you can use XML binding too. In general, there are number of serialization libraries/approaches: XStream (for XML but not for JSON) Jackson (for JSON) Jackson xml module (faster than XStream) Kryo (a fast, compact binary serialization format) Smile (a binary format that comes with Jackson 1.6 and later). Java Object Serialization. SimpleXML seems solid, runs at 2x the speed of XStream, but requires more configuration effort YamlBeans SnakeYAML Jackson JSON, Kryo, and Jackson Smile are all significantly faster than good old Java Object Serialization, by about 3x to 4.5x. XStream is on the slow side.

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.