w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to navigate between different nested ViewModels?
As I implement the INotifyPropertyChanged interface directly in my data classes, I don't have any nested view models, but I do have nested, or hierarchical data classes. In my base collection class, I have a property named CurrentItem of the same type as the items in the collection. When I bind one of these collections to the ItemsSource property of a collection control, I also bind the CurrentItem property to the SelectedItem property of the control. This essentially means that I always know which is the current item in each collection. If you implement one of these CurrentItem properties then you will always know which AppleItem or AppleNote is selected. You don't have to put these properties into collection classes... you could just add properties of the correct type to your view mod

Categories : C#

Knockout binding nested viewmodels
Are you having issues with scope. How about: <div class="section"> <div data-bind="if: $root.general().Condition1 || $root.general().Condition2"> <!-- ko with: deal --> <label>Is this a New Client?</label> <input type=" radio " name="RadioGroup " id="Radio1 " value="true " data-bind="checkedRadioToBool: NewClient" /> <label for="radio1 ">Yes</label> <input type="radio " name="KSTProcurmentRadio " id="Radio2 " value="false " data-bind="checkedRadioToBool: NewClient " /> <label for="radio2 ">No</label> <!-- /ko --> </div> </div>

Categories : Javascript

binding nested viewmodels: knockout
The submenu property contains no items. In this fiddle I just add a fake item and the resuting view shows a fakeSubMenu element. So I think you only have add items in the submenu property and it will work. This is what I done : ProductMenu= function(name, subProductsMenu1, selectedMenu) { var self= this; self.productname = ko.observable(name); self.submenu = ko.observableArray([{subMenuName: 'fakeSubMenuName'}]); self.selectedProductName = ko.observable(); }; I hope it helps. See fiddle

Categories : Knockout Js

Can't get my binding with nested viewModels to work with objects instead of strings
With this code it will work as excpected. HTML: <table> <tbody data-bind="foreach: inners"> <tr> <td> <p data-bind="text: selectedOption"></p> </td> <td> <select data-bind="options: $root.options, optionsText: 'name', optionsValue: 'value', value: selectedOption"></select> </td> </tr> </tbody> </table> javascript: var InnerModel = function(n){ var self = this; self.name = ko.observable(n); self.selectedOption = ko.observable(2); }; var OuterModel = function(){ var self = this; self.inners = new ko.observableArray([new InnerModel('

Categories : Javascript

Difficulties using PHP to authenticate with CAS
OK I think I solved the problem with cURL. I didn't have the CURLOPT_SSL_VERIFYPEER set to false and that's why it was failing. I can now get the XML response with PHP, process the XML response and retrieve the user ID. Here's the code: // Get the current server address we are executing the PHP from $currentProtocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https://' : 'http://'; $requestUri = explode('?', $_SERVER['REQUEST_URI']); $requestUri = $requestUri[0]; $ticket = $_GET['ticket']; $port = ($_SERVER['SERVER_PORT'] != 80) ? ':' . $_SERVER['SERVER_PORT'] : ''; # Don't need the port if it's 80, but needed if for example test server is running port 8080 $currentUrl = $currentProtocol . $_SERVER['SERVER_NAME'] . $port . $requestUri; // Setup the validation

Categories : PHP

Makefile Difficulties
You need to compile both .c files and link them both into your executable. You need a dependency on clientfunctions.o in your client target and to include this object in your link to do this client: client.o clientfunctions.o gcc client.o clientfunctions.o -o client

Categories : C

VB.NET Console and RichTextBox difficulties
You need to match just the part with the console output > and then replace that portion of the string with empty space, like this: If RichTextBox1.Text.Contains("console output >") Then Console.WriteLine(Replace(RichTextBox1.Text, "console output >", "")); End If

Categories : Vb.Net

android and sqlite difficulties
Pass db as a parameter to populateTable() when calling that method from onCreate(). You already have the db open from onCreate(), no need to get a writable database again. onCreate would look like this: @Override public void onCreate(SQLiteDatabase db) { // TODO Auto-generated method stub String CREATE_TABLE = "CREATE TABLE " + DATABASE_TABLE + "(" + COUNTRY + " TEXT," + INDICATOR + " TEXT," + DESCRIPTION + " TEXT" + ")"; db.execSQL(CREATE_TABLE); populateTable(db); } and start of populateTable() would look like this: public void populateTable(SQLiteDatabase db) { ContentValues cv = new ContentValues(); cv.put(COUNTRY, "France"); cv.put(INDICATOR, "Do"); ... } For the second error, problem is probably your column names. T

Categories : Android

Using ROCR package difficulties
I had the same issue... If you look closely, it says: Loading required package: gplots Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘KernSmooth’ In addition: Warning messages: 1: package ‘ROCR’ was built under R version 3.0.3 2: package ‘gplots’ was built under R version 3.0.3 Error: package ‘gplots’ could not be loaded I simply installed the install.packages("gplots") and then loaded the library and it loaded and found the function without any issues. Hope this helps

Categories : R

BlackJack Class Difficulties
Your Deck cards are all strings: self.Deck = ['J', 'J', 'J', 'J', 'Q', 'Q', 'Q', 'Q', 'K', 'K', 'K', 'K', 'A', 'A', 'A', 'A', '2', '2', '2', '2', '3', '3', '3', '3', '4', '4', '4', '4', '5', '5', '5', '5', '6', '6', '6', '6', '7', '7', '7', '7', '8', '8', '8', '8', '9', '9', '9', '9', '10', '10', '10', '10'] Note the '2' and '3', etc. strings. Yet you try to treat them as integers: for x in self.hand: if x != ',': if x not in range(1, 11): x will never be in range(1, 11), because all your values are strings. So the above if statements are always True. The next part is: if x != 'A': self.value += 10 else: if (self.value + 11) > 17: self.value += 1 else: self.value += 11 When 'number' cards are drawn, the not in range(1, 11) is still true

Categories : Python

Having simple difficulties with encapsulation
The problem is that your class Data, which owns the XMLtext field is an instance class. Your method XMLread is static, meaning it is shared across all instances of Data. To solve your problem either make XMLText static or make XMlread an instance method by removing the static keyword.

Categories : C#

Difficulties with dispalying progressdialog
Don't use .get() as you have seen it blocks the UI. You can use getStatus() if you need to check if the task is finished. Removing .get() should allow your ProgressDialog to show. If you have code that must wait until the AsyncTask is finished then put it in onPostExecute() or call a function from there If you need to reference something in the MainActivity from the AsyncTask after it has finished, simply create a constructor to take a reference of your Activity and pass context to your constructor Operation o = new Operation(this); and reference it in constructor lass Operation extends AsyncTask<String, Void, JSONObject> { ProgressDialog pd; Context con; Activity act; public Operator(Activity curAct) { act = curAct; // can use this reference to access m

Categories : Android

.htaccess difficulties with directory
^nl/provincies/plaatsen/(.*)$ section.php?sid=plaatsend&plaats=$1 ...this will never match the URL you've given? Anyway what you're looking for is something like: RewriteRule ^(.+)/provincies/([^/]+)$ section.php?sid=plaatsend&plaats=$2 RewriteRule ^(.+)/provincies/.+/plaats/(.+)$ section.php?sid=plaatsend&province=$2 Or more generic: RewriteRule ^(.+)/provincies/([^/]+)(/plaats/)?(.+)?$ section.php?sid=plaatsend&province=$2&plaats=$4&locale=$1 For complex rewriting like this I would however sincerely recommend doing it in PHP.

Categories : Regex

Asp.net Where to build viewmodels
You should keep mapper logic at BL in seperate class not at controllers. Thats mainly because Its not the responsibilty of your controller to do the mapping. There should be another class to handle this mapping responsibilty. That's what SRP principle says, I think. Better you have a look on some Object Oriented design SOLID OOD Principles.

Categories : C#

DI of a service used by many different ViewModels
Everything seems fine, you are injecting dependencies and using factories, these are good practices. Regarding ViewManager instance, if ViewManager is singleton - it does not matter how to access it - using a factory or any other reference to ViewManager must return the same instance. And I do not see why you should keep many instances of ViewManager, but it depends on your specific application design. So please share IViewManager interface declaration and give some comments for each method so it will be clear whether IViewManager should be a singleton or not. Some points to concern Is ViewManager stateless? Is there any functionality which obligates ViewManager to keep references to all View instancess?

Categories : Dotnet

Asp.Net MVC Adding two viewmodels to a third
Contacts is of Type List<MV1>, thus you can't assign it to a Property of type VM1. You need to change the definition of VM3 to: public class VM3 { public List<VM1> VM1 { get; set; } public List<VM2> VM2 { get; set; } }

Categories : C#

Where to use Entities and ViewModels
Based on my understanding, it depends on the scope of your application. You can return the entities to the business layer if you have a simple usage, say you are using all the properties of the entity class in the view. Suppose, if you have a complex model where you want a combination of different entities that you are going to use in the view, then you use view models. In the latter case you save all the data into view model in data-access layer and return the view model to business layer or you can get the models into business layer and save them into view model at this level and return to the controller action method. But the controller action method should finally get the view model.

Categories : Asp Net Mvc

Switching between viewmodels
Switching VMs is not the route to go mostly due to data binding. Each page should have its own VM. That doesn't mean you can't share VMs though. Have the main page VM have each other VM, then when you switch, take that change into account with the data bindings.

Categories : C#

html sanitization makes difficulties
I prefer to follow OWASP RULE#2: > RULE #2 - Attribute Escape Before Inserting Untrusted Data into HTML Requirements: -Aggressive HTML Entity Encoding -Only place untrusted data into a whitelist of safe attributes (listed below). -Strictly validate unsafe attributes such as background, id and name. Please see XSS (Cross Site Scripting) Prevention Cheat Sheet

Categories : PHP

XML - Understanding difficulties parsing XML using JDOM
node.getAttributes() gives you a list of attributes which you can iterate over again. The ouput you see is just the result of the lists toString() methode which is called when you hand it over to System.out.println(). Do something like this: for(Attribute attribute : node.getAttributes()) { String attributeName = attribute.getName(); String value = attribute.getValue(); } There are also other get-methods that already return a certain type (like getIntValue()). Look at the Attribute documentation

Categories : Xml

difficulties on locating javascript and css codeigniter
do your really need that 'dot' after your closing php tag? <?php echo base_url(); ?>./ also remove extra leading slashes: <link href="<?php echo base_url(); ?>css/jquery.ui.css" /> <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.js"></script> <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.ui.js"></script> p.s make sure that base_url is set properly in your config file: $config['base_url']='localhost/websitename/' with a trailing slash

Categories : Javascript

Additional Include Directories Difficulties
The rules here are very simple. Say you have a file on your hard drive: C:abcdefincludeFTGLftgl.h Then you need to add an include path C:abcdef to your project and the include statement: #include <include/FTGL/ftgl.h> This was tested 1000 times. Works fine! Once you will make this working, start experimenting with $(Project1) and other VS variables.

Categories : C++

Hide/show Layout difficulties
When using RelativeLayout you will need to add some additional properties to the children to tell Android how you want them laid out. You have two possible options, RelativeLayout and LinearLayout; RelativeLayout Note that I've missed out your other attributes for brevity, but they should still be included. The critical parts are the android:layout_below attributes. If you don't include them then views are just attached overlapping each other as you have already observed. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" > <LinearLayout android:id="@+id/atcTypeLinear"

Categories : Android

Difficulties with Matlab12b function imshow()
If I type help imshow in MATLAB, the first paragraph reads: IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the display range for I in [LOW HIGH]. The value LOW (and any value less than LOW) displays as black, the value HIGH (and any value greater than HIGH) displays as white. Values in between are displayed as intermediate shades of gray, using the default number of gray levels. If you use an empty matrix ([]) for [LOW HIGH], IMSHOW uses [min(I(:)) max(I(:))]; that is, the minimum value in I is displayed as black, and the maximum value is displayed as white. so [] is simply shorthand for [min(pixel_labels(:)) max(pixel_labels(:))].

Categories : Image

converting entities to viewmodels for use with web api
I strongly suggest use of a mapping plugin for this, such as: AutoMapper or ValueInjector Plugins like this will allow you to map between the objects being used internally or in your data layer, with your external objects (DTOs/ViewModels). They handle a number of things out of the box such as automatic mapping of any like named properties with the same type, but also allow for a lot of control in the specific mapping of properties or types, for those times when you need something more custom. For a brief comparison of the two, there isn't much better than hearing the authors themselves respond: AutoMapper vs ValueInjecter Personally, I find ValueInjector to be quicker to use, while having more control overall, but I also find it to be much less readable/inuitive than AutoMapper, whi

Categories : C#

Populating SelectLists in viewmodels
You don't need an EmployeeName property. Do this in your controller: var emp = iEmployeeRepository.FindBy(x => x.Active == true) .OrderBy(x => x.FirstName) .Select(x => new { EmployeeId = x.EmployeeId, EmployeeName = x.FristName + " " + x.LastName }); var equipmentViewModel = new EquipmentViewModel { EquipmentId = e.EquipmentId, EquipmentName = e.EquipmentName, OriginatorEmployeeId = e.OriginatorEmployeeId, EmployeeList = new SelectList(emp, "EmployeeId", "EmployeeName"), }; return View(equipmentViewModel);

Categories : Asp Net Mvc

Communication between ViewModels via events
You don't need to re-invent the wheel when its already there. Use EventAggregator which internally uses weak event pattern to prevent any memory leaks. Refer to tutorials here and here. Also you can use Event Aggregator with Reactive Extensions. Refer to the post for viable approaches you can reuse - Even Aggregator Implementation Sample/Best Practices.

Categories : C#

ASP.NET MVC 4 Error Saving ViewModels
This line at the top of your Action is wrong: if (ModelState.IsValid) { return View(studentViewModel); } It should be the opposite, only if the Model is NOT valid, then you should stop the process and re-render the View with the form. Try: if (!ModelState.IsValid) { return View(studentViewModel); }

Categories : Asp Net Mvc

Working with Breeze + ViewModels
@ridermansb - Because you mentioned AutoMapper, I will assume that your mapping is taking place on the server. You want your server API to expose "ViewModels" (in this case you might call them DTOs) rather than the domain model objects. Sometimes your ViewModels mirror your domain objects exactly; sometimes they don't. Your client only sees what your API exposes. If this is a BreezeJS client, you will likely treat the ViewModels as client-side entities. They are Breeze entities in the sense that you expect Breeze to query, cache, change-track, and validate them. BreezeJS doesn't know whether these "entities" correspond to server-side DTOs or server-side business objects. Of course if you're using DTOs/ViewModels, your server code is responsible for translating between the DTO form and t

Categories : Asp Net Web Api

Do I make viewmodels for each page?
Well since a view model acts as interface to your model from your view, it makes sense that any time a view needs to modify a model differently than any other view has, you'll want a new view model. In other words, even though various views may LOOK different, it's the interaction with the model/view model that dictates whether a new view model is necessary.

Categories : C#

Difficulties fading out and hiding Relative Layout
I think you should have this in an anim xml file where you would want this: <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:fromAlpha="1.0" android:toAlpha="0.0" android:interpolator="@android:anim/accelerate_interpolator" android:duration="1000"/> </set> I think your problem is that the interpolator isn't defined. So try to put this line's equivalent in your code: android:interpolator="@android:anim/accelerate_interpolator" Hope it helps EDIT: did a little research, it looks like you want to say fadeOutAnimation.setInterpolator(new AccelerateInterpolator());

Categories : Java

Timing Difficulties in Effort to Fade Images In and Out
Try something like this for crossfade animation - (void)crossfade { [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ self.animationImageView.alpha = 0.0; }completion:^(BOOL done){ [self performAnimationOnView]; [UIView animateWithDuration:0.3 delay:0.0 options:UIViewAnimationOptionCurveEaseIn animations:^{ self.animationImageView.alpha = 1.0; }completion:^(BOOL done){ }]; }]; }

Categories : Iphone

Slick: Difficulties working with Column[Int] values
Let's start with the problem: val q = for { x <- Users if foo((x.userId, x.userName), where) } yield x See, Slick transforms Scala expressions into SQL. To be able to transform conditions, as you want, into SQL statement, Slick requires some special types to be used. The way these types works are actually part of the transformation Slick performs. For example, when you write List(1,2,3) filter { x => x == 2 } the filter predicate is executed for each element in the list. But Slick can't do that! So Query[ATable] filter { arow => arow.id === 2 } actually means "make a select with the condition id = 2" (I am skipping details here). I wrote a mock of your foo function and asked Slick to generate the SQL for the query q: select x2."UserId", x2."UserName" from "Users" x2 where

Categories : Database

I am having difficulties getting my query to work correctly. Can you please assist?
I've tried to give you some idea on how it could be done, though I'm not exactly sure about the column names and resulting column: with SingleAnswers (QuestionID,SurveyID,Username,TotalSingle) as( Select SQ.QuestionID,S.SurveyID, Username,count(*)TotalSingle from SurveyAnswers SA join surveychoices SC on SA.choiceId = SC.choiceId join surveyquestions SQ on SQ.QuestionID = SC.QuestionID JOIN Survey S ON SQ.SurveyID = S.SurveyID where SA.ChoiceID is Not Null and username = @UserName and SC.iscorrect='True' and SQ.AnswerType='S' group by SQ.QuestionID,S.SurveyID, Username) ,MultipleAnswers (QuestionID,SurveyID,Username,TotalMultiple) as( Select SQ.QuestionID,S.SurveyID, Username,count(*)TotalMultiple from SurveyAnswers SA join surveychoi

Categories : SQL

difficulties facing with multiple selection in listview
In your ListViewAdapter when creating view for a list item, use setTag() on the "more"-TextView to add its pr_id to it. In more's listener call getTag() to retrieve the right id.

Categories : Android

Inject the same service instance in many ViewModels
The best way if you're using MVVM is to use an MVVM framework. To answer your question, you would want the view manager to be injected via the factory constructor, rather than the factory method, so option 1. Really though you don't want to be managing view instances yourself - rather use a framework which has already done all of the work for you, rather than reinventing an inferior wheel.

Categories : Dotnet

ASP.Net MVC C# two viewmodels within another viewmodel - how to reference in the view
I think you made an error on your view, you return a PostListAndReplyVM on your controller and your view reference an IEnumerable of PostListAndReplyVM. You have to change the declarated model in your view @model centreforum.Models.PostListAndReplyVM Hope it's help

Categories : C#

Views, ViewModels, "WindowViewModels" ...what am I missing here?
In my opinion, too many. Architecture should be flexible and you might not keep sticking to one of technique, like IOC, when you smell something. On one hand I did not see the benefit of ISomeDomainModelEntityViewModel, ISomeWindowViewModel and IObservableCollection, there is only one class for each interface, except DI and on the other hand, interface is not essential for DI. I think you might take a look Prism examples to see how they construct ViewModel with DI and when to use interfaces. Usually, if you want to use DI to construct a ViewModel, all dependencies of the ViewModel are services, defined in interface and use IOC to resolve these services. Since these services like have external dependencies so that mocking these interfaces to test is easy. However, most of ViewModel does no

Categories : C#

How to show data from two ViewModels in one View
You need to update the type of you view. You are not passing the view a list of Chat.Models.ChatLogsUsersViewModel, you only have one and this model has two lists. So update it to: @model Chat.Models.ChatLogsUsersViewModel

Categories : C#

How binding several ViewModels in MainWindow.xaml?
<Window.Resources> <viewModels:MainWindowViewModel x:Key="Windows1ViewModel" /> <viewModels:OtherViewModel x:Key="OtherViewModel" /> </Window.Resources> <Grid DataContext="{StaticResource Windows1ViewModel}"> <TextBox DataContext="{StaticResource OtherViewModel}" "require to bind OtherVeiwModel here"/> </Grid> Alternately your MainViewModel might be keeping a reference to your OtherViewModel , you can bind the TextBox's DataContext to that alternate view model. CS: public class MainViewModel { public OtherViewModel OtherViewModel{get {retrurn new OtherViewModel();}} } XAML : <TextBox DataContext="{Binding OtherViewModel, Mode=OneWay}" "require to bind OtherVeiwModel here"/>

Categories : C#



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