i have doubt in Private fields, variables and methods, if i created a class that contains private variables and methods then how can i use, when to go for private members, methods and when to not use?
I have a set field in my db that is longtext. I have used prices in this field and cannot change the field type to integer. In my query however I need to sort by these fields and assume I should treat them as an integer. is there another way to query these results to sort by price as an integer and not longtext without having to change the field type?
at the moment 3900000 is smaller than 4300 in my result set.
Hello, I just hit a situation where a method dispatch was ambiguous and wondered if anyone could explain on what basis the compiler (.NET 4.0.30319) chooses what overload to call
interface IfaceA
{
}
interface IfaceB<T>
{
void Add(IfaceA a);
T Add(T t);
}
class ConcreteA : IfaceA
{
}
class abstract BaseClassB<T> : IfaceB<T>
{
public virtual T Add(T t) { ... }
public virtual void Add(IfaceA a) { ... }
}
class ConcreteB : BaseClassB<IfaceA>
{
// does not override one of the relevant methods
}
void code()
{
var concreteB = new ConcreteB();
// it will call void Add(IfaceA a)
concreteB.Add(new ConcreteA());
}
In any case, why does the compiler not warn me or even why does it compile?
Thank you very much for any answers.
I know it can't be done since using var can only be done for local variables. I'm just wondering if anyone has a theory why the C# team thought this should be so. e.g. what would be wrong with this:
public class SomeClass
{
var someString = "hello"; //not cool
public SomeClass()
{
var someOtherString = "hello"; //cool
}
}
If someString is initialised then it is obviously a string just like someOtherString. Why is there one rule for local variables and another for globals?
I'd like to know how to call a GWT static method from the parent of the iframe in which the gwt module is loaded.
As a simple example suppose I have the following gwt class:
public class Simple {
public static void showWindow() {
Window.alert("Hello from the iframe");
}
}
I create an html host page called "iFrameHost.html" that can run the function above. Then in an unrelated GWT module on a different page I call:
Frame iFrame = new Frame("iFrameHost.html");
RootPanel.get().add(iFrame);
How do I now call the showWindow() method from the parent page?
Let's assume I have a table magazine:
CREATE TABLE magazine
(
magazine_id integer NOT NULL DEFAULT nextval(('public.magazine_magazine_id_seq'::text)::regclass),
longname character varying(1000),
shortname character varying(200),
issn character varying(9),
CONSTRAINT pk_magazine PRIMARY KEY (magazine_id)
);
And another table issue:
CREATE TABLE issue
(
issue_id integer NOT NULL DEFAULT nextval(('public.issue_issue_id_seq'::text)::regclass),
number integer,
year integer,
volume integer,
fk_magazine_id integer,
CONSTRAINT pk_issue PRIMARY KEY (issue_id),
CONSTRAINT fk_magazine_id FOREIGN KEY (fk_magazine_id)
REFERENCES magazine (magazine_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
Current INSERTS:
INSERT INTO magazine (longname,shotname,issn)
VALUES ('a long name','ee','1111-2222');
INSERT INTO issue (fk_magazine_id,number,year,volume)
VALUES (currval('magazine_magazine_id_seq'),'8','1982','6');
Now a row should only be inserted into 'magazine', if it does not already exist. However if it exists, the table 'issue' needs to get the 'magazine_id' of the row that already exists in order to establish the reference.
How can i do this?
Thx in advance!
Hi,
I have the following problem. I need to export a PDF in a controller
The code below, where I return a View, works as expected.
@RequestMapping(method = RequestMethod.GET)
public View exportReport(
@RequestParam(value = "userName", required = true) String userName,
@RequestParam(value = "startDate", required = true) Date startDate,
@RequestParam(value = "endDate", required = true) Date endDate) {
///////////////////////////////////////////
return new TimeSheetReportPdfView();
}
The problem occurs if I change the method to return a ModelAndView:
@RequestMapping(method = RequestMethod.GET)
public ModelAndView exportReport(
@RequestParam(value = "userName", required = true) String userName,
@RequestParam(value = "startDate", required = true) Date startDate,
@RequestParam(value = "endDate", required = true) Date endDate) {
///////////////////////////////////////////
return new ModelAndView(new TimeSheetReportPdfView(), model);
}
Now, the PDF is not exported, all I get is a blank page and nothing in the logs.
Any help appreciated.
Thanks.
Hello All!
I have a query with grouping on one of the fields in Crystal Reports. My question is - is there a way to pass that value into a subreport?
I.e. if there are three values in that field, there will be three groups in report. I want a subreport in every group to have that value as its parameter.
Is that possible to accomplish with CR 2008?
Hi.
I am new to LWUIT and j2me,
and I am building a j2me application for showing Japanese text vertically. The phonetic symbol part of the text should be shown in relatively small font size (about half the size of the text), small Kanas need to be shown as normal ones, and some 'vertical only' characters need to be put into the Private Use Area, etc.
I tried to build this font into a bitmap font using the FontTask ant task LWUIT provided, but found that it does support the customizations mentioned above. So I decided to write my own task and add those.
Below is what I have achieved:
1 An ant task extending the LWUITTask task to support a new nested element <verticalfont>.
public class VerticalFontBuildTask extends LWUITTask {
public void addVerticalfont(VerticalFontTask anVerticalFont) {
super.addFont(anVerticalFont);
}
}
2 The VerticalFontTask task, which extends the original FontTask. Instead of inserting a EditorFont object, it inserts a VerticalEditorFont object(derived from EditorFont) into the resource.
public class VerticalFontTask extends FontTask {
// some constants are omitted
public VerticalFontTask() {
StringBuilder sb = new StringBuilder();
sb.append(UPPER_ALPHABET);
sb.append(UPPER_ALPHABET.toLowerCase());
sb.append(HALFWIDTH);
sb.append(HIRAGANA);
sb.append(HIRAGANA_SMALL);
sb.append(KATAKANA);
sb.append(KATAKANA_SMALL);
sb.append(WIDE);
this.setCharset(sb.toString());
}
@Override
public void addToResources(EditableResources e) {
log("Putting rigged font into resource...");
super.addToResources(e);
//antialias settings
Object aa = this.isAntiAliasing()
? RenderingHints.VALUE_TEXT_ANTIALIAS_ON
:RenderingHints.VALUE_TEXT_ANTIALIAS_OFF;
VerticalEditorFont ft = new VerticalEditorFont(
Font.createSystemFont(
this.systemFace,
this.systemStyle,
this.systemSize),
null,
getLogicalName(),
isCreateBitmap(),
aa,
getCharset());
e.setFont(getName(), ft);
}
VerticalEditorFont is just a bunch of methods logging to output and call the super. I am still trying to figure out how to extend it.
But things are not going well: none of the methods on the VerticalEditorFont object get called when executing this task.
My questions are:
1 where did I do wrong?
2 I want to embed a truetype font to support larger screens. I only need a small part of the font inside my application and I don't want it to carry a font resource weighing 1~2MB. Is there a way to extract only the characters needed and pack them into LWUIT?
I am new to Design Pattern and I have a scenario here... and not sure as how to implement the pattern ...
We have multiple vendors Philips, Onida...
Each vendor (philips, onida...) may have different type of product i.e. Plasma or Normal TV
I want specific product of each vendor using Abstract Factory Pattern...
Thanks in advance for any help...
My implementation so far...
public enum TvType
{
Samsung = 0,LG = 1,Philips = 2, Sony = 3
}
public enum Product
{
Plasma = 0,NormalTV = 1
}
concrete class of each vendor.... that returns each product and also the interface that contains ProductInfo i.e. if Vendor is ... then it must have this product....
I have one table, which has three fields and data.
Name , Top , Total
cat , 1 , 10
dog , 2 , 7
cat , 3 , 20
horse , 4 , 4
cat , 5 , 10
dog , 6 , 9
I want to select the record which has highest value of Total for each Name, so my result should be like this:
Name , Top , Total
cat , 3 , 20
horse , 4 , 4
Dog , 6 , 9
I tried group by name order by total, but it give top most record of group by result. Can anyone guide me, please?
I disassembled the .NET 'System' DLL and looked at the source code for the variable classes (string, int, byte, etc.) to see if I could figure out how to make a class that could take on a value. I noticed that the "Int32" class inherits the following: IComparable, IFormattable, IConvertible, IComparable, IEquatable.
The String and Int32 classes are not inheritable, and I can't figure out what in these inherited interfaces allows the classes to hold a value. What I would want is something like this:
public class MyVariable : //inherits here
{
//Code in here that allows it to get/set the value
}
public static class Main(string[] args)
{
MyVariable a = "This is my own custom variable!";
MyVariable b = 2976;
if(a == "Hello") { }
if(b = 10) { }
Console.WriteLine(a.ToString());
Console.WriteLine(a.ToString());
}
I have an imageview with a default image already set from the xml, and I want to change it's image pragmatically so that the new image will scale to the previous image size, both of the images are rounded.
I have tried setting the scaleType attribute to different values before setting the new image but it didn't work.
This is the xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/up_right_circle_firstiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:scaleType="fitXY"
android:src="@drawable/circle_medium_up" />
This is the activity code:
public class MainActivity extends Activity {
ImageView middleCircle;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
middleCircle = (ImageView) findViewById(R.id.up_right_circle_firstiv);
middleCircle.setImageResource(R.drawable.round_pic_one);
}
}
Inside the activity.
I have uploaded the screenshots:
http://imgur.com/OM79T
http://imgur.com/G7y3Q
I'm using jQuery.serialize to retrieve all data fields in a form.
My problem is that it does not retriev checkboxes that is not checked.
It includes this:
<input type="checkbox" id="event_allDay" name="event_allDay" class="checkbox" checked="checked" />
but not this
<input type="checkbox" id="event_allDay" name="event_allDay" class="checkbox" />
How can I get "values" of checkboxes that is not checked?
I have a class that is derived from ostream:
class my_ostream: public std::ostream
{
// ...
}
I want to make a manipulator (for example do_something), that works specifically to this class, like this:
my_ostream s;
s << "some text" << do_something << "some more text";
I did the following:
std::ostream &do_something(std::ostream &os)
{
my_ostream *s = dynamic_cast<my_ostream*>(&os);
if (s != NULL)
{
// do something
}
return os;
}
This works, but is rather ugly. I tried the following:
my_ostream &do_something(my_ostream &s)
{
// do something
return s;
}
This doesn't work. I also tried another approach:
class my_ostream: public std::ostream
{
// ...
my_ostream &operator<<(const do_something & x)
{
// do something
return *this;
}
}
This still doesn't work.
Hi Guys,
I have the following two action methods (simplified for question):
[HttpGet]
public ActionResult Create(string uniqueUri)
{
// get some stuff based on uniqueuri, set in ViewData.
return View();
}
[HttpPost]
public ActionResult Create(Review review)
{
// validate review
if (validatedOk)
{
return RedirectToAction("Details", new { postId = review.PostId});
}
else
{
ModelState.AddModelError("ReviewErrors", "some error occured");
return RedirectToAction("Create", new { uniqueUri = Request.RequestContext.RouteData.Values["uniqueUri"]});
}
}
So, if the validation passes, i redirect to another page (confirmation).
If an error occurs, i need to display the same page with the error.
If i do return View(), the error is displayed, but if i do return RedirectToAction (as above), it loses the Model errors.
I'm not surprised by the issue, just wondering how you guys handle this?
I could of course just return the same View instead of the redirect, but i have logic in the "Create" method which populates the view data, which i'd have to duplicate.
Any suggestions?
Hi all
Have you ever used lazy C++?
I am trying to create .CPP files out of .H files. In forum I read that it is possible with your tool but I tried touse it and I didn't succeed.
Can you help me?
I used the option -c with a Test.h file with exactly the following declaration.
class TEST_A
{
public:
TEST_A();
~TEST_A();
void fooA( MyNamespace::String& aName );
};
The only thing I have is a Cpp file with written
#define LZZ_INLINE
#undef LZZ_INLINE
and the .h file modified with before the class
#define LZZ_LINE inline
class TEST_A
{
public:
TEST_A();
~TEST_A();
void fooA( MyNamespace::String& aName );
};
#undef LZZ_LINE
What I am doing wrong?
I am looking at Skeet's AtomicEnumerable but I'm not sure how to integrate it into my current IEnumerable exmaple below (http://msmvps.com/blogs/jon_skeet/archive/2009/10/23/iterating-atomically.aspx)
Basically I want to foreach my blahs type in a thread-safe way.
thanks
public sealed class Blahs : IEnumerable<string>
{
private readonly IList<string> _data = new List<string>() { "blah1", "blah2", "blah3" };
public IEnumerator<string> GetEnumerator()
{
return _data.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
namespace Dic
{
public class Key
{
string name;
public Key(string n) { name = n; }
}
class Program
{
static string Test()
{
Key a = new Key("A");
Key b = new Key("A");
System.Collections.Generic.Dictionary<Key, int> d = new System.Collections.Generic.Dictionary<Key, int>();
d.Add(a, 1);
return d.ContainsKey(b).ToString();
}
static void Main(string[] args)
{
System.Console.WriteLine(Test());
}
}
}
I want TRUE!!!
I would like to determine what the long url of a short url is. I have tried using http HEAD requests, but very few of the returned header fields actually contain any data pertaining to the destination/long url.
Is there:
1. Any way to determine the long url?
2. If so, can it be done without downloading the body of the destination?
Thank you
I'm working through NerdDinner and I'm a bit confused about the following section...
First they've added a form for creating a new dinner, with a bunch of textboxes delcared like:
<%= Html.TextArea("Description") %>
They then show two ways of binding form input to the model:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create() {
Dinner dinner = new Dinner();
UpdateModel(dinner);
...
}
or:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Dinner dinner) { ... }
Ok, great, that all looks really easy so far.
Then a bit later on they say:
It is important to always be paranoid
about security when accepting any user
input, and this is also true when
binding objects to form input. You
should be careful to always HTML
encode any user-entered values to
avoid HTML and JavaScript injection
attacks
Huh? MVC is managing the data binding for us. Where/how are you supposed to do the HTML encoding?
there!
I have this question, hope you guys can help me out.
So i have this table with two fields:
type and authorization
in type i have 2 different values: Raid and Hold
in authorization i have 2 different values: Accepted or Denied
I need to make a view that returns values like this:
TYPE:RAID ACCEPTED:5 DENIED:7
Basically i need to know how many of the values in TYPE are Raid, and then how many of
them are Accepted and Denied.
Thank you in advance!!
I have an application with several graphs and tables on it.
I worked fast and just made classes like Graph and Table that each contained a request object (pseudo-code):
class Graph {
private request;
public function setDateRange(dateRange) {
request.setDateRange(dateRange);
}
public function refresh() {
request.getData(function() {
//refresh the display
});
}
}
Upon a GUI event (say, someone changes the date range dropdown), I'd just call the setters on the Graph instance and then refresh it. Well, when I added other GUI elements like tables and whatnot, they all basically had similar methods (setDateRange and other things common to the request).
What are some more elegant OOP ways of doing this?
The application is very simple and I don't want to over-architect it, but I also don't want to have a bunch of classes with basically the same methods that are just routing to a request object. I also don't want to set up each GUI class as inheriting from the request class, but I'm open to any ideas really.
I'm a big fan ov 8020.com and my goal is to create a porfolio with the same functionality like the one they have. Here is my markup
This section should be hidden
<section id="work-container">
<div id="work-list-51" class="work-details">
<h1>
<div class="close-project">
</div>
<div id="work-list-52" class="work-details">
<h1>
<div class="close-project">
</div>
<div id="work-list-53" class="work-details">
<h1>
<div class="close-project">
</div>
</section>
This section will hold the thumbnails. When you click a thumbnail you will scroll to the top and the div will slidetoggle.
<ul id="work-list">
<li id="work-list-51"><a data-page="51" href="#work-list-51">
<img width="230" height="230" alt="Mariann Rosa" src="sites/default/files/styles/square_thumbnail/public/field/image/mariann.jpg">
</a></li>
<li id="work-list-52"><a data-page="52" href="#work-list-52">
<img width="230" height="230" alt="Mariann Rosa" src="sites/default/files/styles/square_thumbnail/public/field/image/mariann.jpg">
</a></li>
<li id="work-list-53"><a data-page="53" href="#work-list-53">
<img width="230" height="230" alt="Mariann Rosa" src="sites/default/files/styles/square_thumbnail/public/field/image/mariann.jpg">
</a></li>
</ul>
I have come this far:
$(document).ready(function(){
$("#work-list a").click(function(event){
event.preventDefault();
$('html, body').animate (
{scrollTop: $('#top').offset().top}, 800
);
});
$('#work-list a').click(function(e) {
$('#work-container > div').hide();
$(this.hash).slideToggle(1600);
});
});
It scrolls to top and the div becomes visible but it does not work correctly :)
I have a baseclass with a protected static ArrayList. I want to have a seperate ArrayList for each kind of subclass that extends this baseclass. This is when I applied CRTP:
public class BaseExample<T> {
protected static ArrayList<Integer> data = new ArrayList<Integer>();
}
This works just fine.
However, when I try to implement the following static method in the same base class, it doesn't adhere to CRTP:
public static void clear() {
data.clear();
}
For example:
class SubExample extends BaseExample<SubExample> {
// insertion methods accessing 'data' field
// these work fine :)
}
SubExample.clear(); // does not seem to clear data container
Do I need to somehow explicitly specify T in my baseclass clear method?
Note: These are all pure static classes.