Hi,
I am trying to create Excel file using OpenXML SDK. I have one situation to get WorkBookPart from WorkSheet instance. How can I get it?
Thanks.
Ant.
Hello Everyone,
I am new to design patterns and am trying to learn the MVC implementation. I have written four classes:
DataModel
DataView
DataController
Main
Main serves as the application facade. The main FLA is called HelloWorld. I have a symbol called "Box" in HelloWorld. I just would like to add an instance of the "Box" on the stage. Eventually I would like to place a button and when the button is clicked, the Box instance color will be changed. I would appreciate any help, please help me figure out what am I doing wrong.
Here are my Classes:
DATAMODEL CLASS:
package
{
import flash.events.*;
public class DataModel extends EventDispatcher
{
public static const UPDATE:String = "modelUpdate";
private var _color:Number = (Math.round(Math.random()* 0xffffff));
public function DataModel()
{
trace("DATA MODEL INIT");
}
public function get color():Number
{
return _color;
}
public function set color(p:Number):void
{
_color = p;
notifyObserver();
}
public function notifyObserver():void
{
dispatchEvent(new Event(DataModel.UPDATE));
}
}
}
//DATACONTROLLER CLASS:
package
{
import flash.events.;
import flash.display.;
import flash.errors.*;
public class DataController
{
private var _model:DataModel;
public function DataController(m:DataModel)
{
trace("DATACONTROLLER INIT");
_model = m;
}
}
}
DATAVIEW CLASS:
package
{
import flash.events.;
import flash.display.;
import flash.errors.*;
public class DataView extends Sprite
{
private var _model:DataModel;
private var _controller:DataController;
private var b:Box;
public function DataView(m:DataModel, c:DataController)
{
_model = m;
_controller = c;
b = new Box();
b.x = b.y = 100;
addChild(b);
}
}
}
And Finally THE FACADE:
package
{
import flash.display.;
import flash.events.;
import flash.text.;
import flash.errors.;
public class Main extends Sprite
{
private var _model:DataModel;
private var _controller:DataController;
private var _view:DataView;
public function Main(m:DataModel, c:DataController, v:DataView)
{
_model = m;
_controller = c;
_view = v;
addChild(v);
}
}
}
When I test the movie: I get this error:
ArgumentError: Error #1063: Argument count mismatch on Main(). Expected 3, got 0.
Thanks alot.
Short of using static IP addresses, is it possible to have a Cisco ASA use a DNS name rather than an IP address? For instance, if I want to limit a host in the DMZ to access only one particular web service, but that web service might be globally load balanced or using DynDNS or cloud, how can the ACL be expressed so that a fixed IP address isn't used and the admin doesn't have to keep opening and closing down IP addresses?
We have a dao as a project (jar file).
Clients use its interfaces and factories to operate with database.
Using standard CRUD operations, dao allows you to search an entity by some search criteria.
What is the best way to represent this criteria?
Is transfer object appropriate pattern in this situation?
How should client create SearchModel instance?
Please, share.
Regards.
i was trying to create a property which is readonly. i wanted to initialize with a value from the class creating an instance of this class.e.g
@property (readonly) NSString *firstName;
And wanted to initialize it like
-(id)initWithName:(NSString *)n{
self.firstName = n;
}
Once i do this, this compiler shows an error that the readonly property cannot be assigned. So how can i do this?
I am experimenting with Less Css, and I am using Visual Studio 2010.
It would be nice if the editor provided support for syntax highlighting and Intellisense for Less, for instance coloring and suggesting variables. What are my options to get that to work ? Do I need to write a plugin for it, or how would one go about adding this to VS ? Does anything exist for this already ?
I'm about ready to bang my head against the wall
I have a class called Map which has a dictionary called tiles.
class Map
{
public Dictionary<Location, Tile> tiles = new Dictionary<Location, Tile>();
public Size mapSize;
public Map(Size size)
{
this.mapSize = size;
}
//etc...
I fill this dictionary temporarily to test some things..
public void FillTemp(Dictionary<int, Item> itemInfo)
{
Random r = new Random();
for(int i =0; i < mapSize.Width; i++)
{
for(int j=0; j<mapSize.Height; j++)
{
Location temp = new Location(i, j, 0);
int rint = r.Next(0, (itemInfo.Count - 1));
Tile t = new Tile(new Item(rint, rint));
tiles[temp] = t;
}
}
}
and in my main program code
Map m = new Map(10, 10);
m.FillTemp(iInfo);
Tile t = m.GetTile(new Location(2, 2, 0)); //The problem line
now, if I add a breakpoint in my code, I can clearly see that my instance (m) of the map class is filled with pairs via the function above, but when I try to access a value with the GetTile function:
public Tile GetTile(Location location)
{
if(this.tiles.ContainsKey(location))
{
return this.tiles[location];
}
else
{
return null;
}
}
it ALWAYS returns null. Again, if I view inside the Map object and find the Location key where x=2,y=2,z=0 , I clearly see the value being a Tile that FillTemp generated..
Why is it doing this? I've had no problems with a Dictionary such as this so far. I have no idea why it's returning null. and again, when debugging, I can CLEARLY see that the Map instance contains the Location key it says it does not...
very frustrating.
Any clues? Need any more info?
Help would be greatly appreciated :)
Dear all. I was wondering if there are examples of situations where you would purposefully pass an argument by value (deep copy) in C. For instance, passing a char to a function is usually cheaper in space than passing a char* (if there's no need to share the value), since char is 1 byte and pointers are, well, whatever they are in the architecture (4 in my 32 bit machine). ?(When) do you want to pass (big) deep copies to functions? if so, why?
How do I use XMLStreamWriter to write exactly what I put in? For instance, if I create script tag and fill it with javascript I don't want all my single quotes coming out as '
How can I force Hibernate to update an entity instance even if the entity is not dirty? I'm using Hibernate 3.3.2 GA, Hibernate Annotations and Hibernate EntityManager btw. I really want Hibernate to execute the generic UPDATE statement even if no property on the entity has changed.
I need this because some event listeners need to get invoked to do some additional work when the application runs for the first time.
Thanks!
I start the executable (after building it with cabal) and it says "Application launched, listening on port 3000." Next I connect to it with my web browser and the console says "threadWaitRead requires -threaded on Windows, or use System.IO.hWaitForInput." The web browser never connects. Not sure what this is actually recommending I do to resolve the problem.
{-# LANGUAGE TypeFamilies, QuasiQuotes, MultiParamTypeClasses,
TemplateHaskell, OverloadedStrings #-}
import Yesod
data HelloWorld = HelloWorld
mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
|]
instance Yesod HelloWorld
getHomeR :: Handler RepHtml
getHomeR = defaultLayout [whamlet|Hello World!|]
main :: IO ()
main = warpDebug 3000 HelloWorld
hi
i m trying to change the state for workflow from one state to another on button click its working fine with windows but not with web application and its instance id does not persist i have used SqlWorkflowPersistenceService also.
what can b the solution for this.
thanks
Hi guys,
I need to delete duplicate users in django (by duplicate I mean two or more users with the same email).
If your instance there are three records like this:
id email
3 [email protected]
56 [email protected]
90 [email protected]
I need to delete records 56 and 90 and leave the oldest record id - 3
Is there a way to quickly do this.
Thanks :)
hi,
in a ModelForm I replaced a field by excluding it and adding a new one
with the same name, as shown below in AddRestaurantForm. When saving
the form with the code shown below, I get an error in form.save_m2m()
("Truncated incorrect DOUBLE value"), which seems to be due to the
function to attempt to save the tag field, while it is excluded.
Is the save_m2m() function supposed to save excluded fields?
Is there anything wrong in my code?
Thanks
Jul
(...)
new_restaurant = form.save(commit=False)
new_restaurant.city = city
new_restaurant.save()
tags = form.cleaned_data['tag']
if(tags!=''): tags=tags.split(',')
for t in tags:
tag, created = Tag.objects.get_or_create(name = t.strip())
tag.save()
new_restaurant.tag.add(tag)
new_restaurant.save()
form.save_m2m()
models.py
class Tag(models.Model):
name = models.CharField(max_length=100, unique=True)
class Restaurant(models.Model):
name = models.CharField(max_length=50)
city=models.ForeignKey(City)
category=models.ManyToManyField(Category)
tag=models.ManyToManyField(Tag, blank=True, null=True)
forms.py
class AddRestaurantForm(ModelForm):
name = forms.CharField(widget=forms.TextInput(attrs=classtext))
city = forms.CharField(widget=forms.TextInput(attrs=classtext), max_length=100)
tag = forms.CharField(widget=forms.TextInput(attrs=classtext), required=False)
class Meta:
model = Restaurant
exclude = ('city','tag')
Traceback:
File "/var/lib/python-support/python2.5/django/core/handlers/base.py"
in get_response
92. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/jul/atable/../atable/resto/views.py" in addRestaurant
498. form.save_m2m()
File "/var/lib/python-support/python2.5/django/forms/models.py" in
save_m2m
75. f.save_form_data(instance, cleaned_data[f.name])
File "/var/lib/python-support/python2.5/django/db/models/fields/
related.py" in save_form_data
967. setattr(instance, self.attname, data)
File "/var/lib/python-support/python2.5/django/db/models/fields/
related.py" in set
627. manager.add(*value)
File "/var/lib/python-support/python2.5/django/db/models/fields/
related.py" in add
430. self._add_items(self.source_col_name,
self.target_col_name, *objs)
File "/var/lib/python-support/python2.5/django/db/models/fields/
related.py" in _add_items
497. [self._pk_val] + list(new_ids))
File "/var/lib/python-support/python2.5/django/db/backends/util.py" in
execute
19. return self.cursor.execute(sql, params)
File "/var/lib/python-support/python2.5/django/db/backends/mysql/
base.py" in execute
84. return self.cursor.execute(query, args)
File "/var/lib/python-support/python2.5/MySQLdb/cursors.py" in execute
168. if not self._defer_warnings: self._warning_check()
File "/var/lib/python-support/python2.5/MySQLdb/cursors.py" in
_warning_check
82. warn(w[-1], self.Warning, 3)
File "/usr/lib/python2.5/warnings.py" in warn
62. globals)
File "/usr/lib/python2.5/warnings.py" in warn_explicit
102. raise message
Exception Type: Warning at /restaurant/add/
Exception Value: Truncated incorrect DOUBLE value: 'a'
Hi,
I have a GridView which has DataKey[0] as productId.
If i have for instance productId = 54, is there any way to search through all
GridView item and set as selected the one who has DataKEy[0] = 54?
In drop down list i have :
ddlProducts.Items.FindByValue(lblProduct.Text.ToString())).Selected = true
Is anything similar for GridView?
Thanks in advance.
As far as I know the Websphere Application Server contains a Tomcat instance as servlet container.
I'd like to know which version of Tomcat this is in the Websphere 7.0 Version, since we are planning to use Tomcat for development, but WAS for deployment. Obviously we would like to use the matching version.
The problem is in being able to catch the instance of the player to control it i.e. Stop it, Play it etc. The code by default creates multiple instances of the same player and overlaps the songs. I am being unable to reference the player specifically.
Do you have an idea as to how we can do so?
Thanks,
Arun
what is the best way to handle floating point numbers in XML?
If I have, for instance:
double a = 123.456;
and I would like to keep it as
<A> 123.456 </A>
simply using
...
myDoc.createTextNode(a.ToString());
is fine?
Or should it be done with some Globalization stuff to make it region-independent?
I have a ModelFormA for ModelA, which has a one-one relationship with ModelB and foreign-key relationship with ModelC.
Inside ModelFormA, I can access attributes of the current ModelA instance via self.cleaned_data["colA-1"]. How would I access attributes of ModelB or ModelC?
I need to force the use of "using" to dispose a new instance of a class.
public class MyClass : IDisposable
{
...
}
using(MyClass obj = new MyClass()) // Force to use "using"
{
}
I have a user profile property. user not assigned any value that property. If I use below code. It is thorwing exception " object reference not set to an instance of an object "
userprof["OptOut"].ToString()
I tried all types
like
if (userprof["OptOut"] != null)
OR
if(userprof["OptOut"].Value != null)
nothing worked out for me.
Here userProf object has value. userprof["OptOut"].Value is null
How to handle this?
For the first time, I'm creating a Java Swing application.
I'm using Windows Builder Pro in Eclipse, and a MySQL database (already setup up).
Let's say I have a combo box, and I want (for instance) all 'name' fields from a 'certain' table appear.
How can I setup that binding? I know how to programatically handle the connection and query code, what I would like to know is how to make that binding in Eclipse.
I'm trying to find some practical applications of a comonad and I thought I'd try to see if I could represent the classical Wumpus world as a comonad.
I'd like to use this code to allow the Wumpus to move left and right through the world and clean up dirty tiles and avoid pits. It seems that the only comonad function that's useful is extract (to get the current tile) and that moving around and cleaning tiles would not use be able to make use of extend or duplicate.
I'm not sure comonads are a good fit but I've seen a talk (Dominic Orchard: A Notation for Comonads) where comonads were used to model a cursor in a two-dimensional matrix.
If a comonad is a good way of representing the Wumpus world, could you please show where my code is wrong? If it's wrong, could you please suggest a simple application of comonads?
module Wumpus where
-- Incomplete model of a world inhabited by a Wumpus who likes a nice
-- tidy world but does not like falling in pits.
import Control.Comonad
-- The Wumpus world is made up of tiles that can be in one of three
-- states.
data Tile = Clean | Dirty | Pit
deriving (Show, Eq)
-- The Wumpus world is a one dimensional array partitioned into three
-- values: the tiles to the left of the Wumpus, the tile occupied by
-- the Wumpus, and the tiles to the right of the Wumpus.
data World a = World [a] a [a]
deriving (Show, Eq)
-- Applies a function to every tile in the world
instance Functor World where
fmap f (World as b cs) = World (fmap f as) (f b) (fmap f cs)
-- The Wumpus world is a Comonad
instance Comonad World where
-- get the part of the world the Wumpus currently occupies
extract (World _ b _) = b
-- not sure what this means in the Wumpus world. This type checks
-- but does not make sense to me.
extend f w@(World as b cs) = World (map world as) (f w) (map world cs)
where world v = f (World [] v [])
-- returns a world in which the Wumpus has either 1) moved one tile to
-- the left or 2) stayed in the same place if the Wumpus could not move
-- to the left.
moveLeft :: World a -> World a
moveLeft w@(World [] _ _) = w
moveLeft (World as b cs) = World (init as) (last as) (b:cs)
-- returns a world in which the Wumpus has either 1) moved one tile to
-- the right or 2) stayed in the same place if the Wumpus could not move
-- to the right.
moveRight :: World a -> World a
moveRight w@(World _ _ []) = w
moveRight (World as b cs) = World (as ++ [b]) (head cs) (tail cs)
initWorld = World [Dirty, Clean, Dirty] Dirty [Clean, Dirty, Pit]
-- cleans the current tile
cleanTile :: Tile -> Tile
cleanTile Dirty = Clean
cleanTile t = t
Thanks!
Anyone familiar with a way how can I can i write something to the stdout from maven.
For instance i would like to write a line everytime i start a new module.
I've got VS2010 installed, I've downloaded the Windows Phone add-in and the Silverlight Toolkit from CodePlex, but I cannot work out for the life of me how to actually use the controls in a Windows Phone 7 application...
How do I add the controls into the toolbox, or link them so that the XAML doesn't give me errors all the time? For instance, using the Viewbox - the controls aren't implemented, and the XAML does not compile.