Thursday, April 19, 2012

How To Create a Rotating Wheel Control?

I am trying to implement the Rotatory wheel in android, just like the image displayed below.I came across the tutorial from this link. But i want to implement just as shown in the below image.The wheel consists of individual images.Does anybody have any idea regarding this implementation?? Any help would be appreciated.



enter image description here



Thanks in advance.



Akash





Can anyone give me a complete introduction using implementation of MVC 3 with NHibernate for connection with mySQL DB

MVCI am new to MVC and ofcourse to MVC 3. I need a tutorial which explains by implementation of MVC 3 and integrate it with mySQL database using NHibernate. It would be really thankful if employee record is fetched from DB to view but I want this with MySQL.
Thanks in Advance.





Passing & in query string

I want to pass '&' operator in query string. I tried to use urlencode and urldecode
but its not working. I am doing this:



$abc="A & B";
$abc2=urlencode($abc);


Then I am passing the value like this



<a href="hello.php?say=<?php echo $abc2 ?>"><?php echo $abc;?></a>


and getting value on next page as



$abc=$_GET['say'];
$abcd=urldecode($abc');
echo $abcd;


but the output is not A & B



What am I doing wrong?





Generating script when using EclipseLink

I am using EclipseLink as JPA implementation and I am adding these properties in the persistence.xml but I can't see any scripts generated? Where are they supposed to be saved or have I misunderstood this property.



<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="both" />


Is it possible to define a script as well that would be run after the tables are created? The same way as a seed script in Rails?





perl redirection linux

sub cdevice{
$p=$_[0];
$s=$_[1];
$q=$_[2];
try {
$device_create_cmd ="create type:NSR Device;media type:adv_file;name:$p;device access information:$p";
system("echo $device_create_cmd > command.txt ");
} catch Error with {
print "Error " ;
exit();
};
}
cdevice("/device1","raddh054","/device1");


this pl file is working fine on Windows but not on Linux because echo in Linux is not accepting spaces between the text !how do i resolve it





Howto Test Databinding with Rhino Mocks and NUnit

I try to test my SW-Project VS2008, .NET 3.5 with "Rhino Mocks" and "NUnit". It uses the MVP Pattern and Databinding, so nothing unusual. But I get a problem (System.ArgumentException) when I try to test the databinding of my controls which occures on System.Windows.Forms.BindToObject.CheckBinding() and is: Cannot bind to the property or column IsOpened on the DataSource. But this only occures in the test. When I run the project everything is fine ... so this might be a problem of my Test definition e.g. Mock definition?



My project looks like the following: (I describe it here with my words and some code. To paste all code here this post will explode, but you can download it here: http://www.speedshare.org/download.php?id=1FD0FF0D11 Password: test)



I've a Presenter:



public class Presenter
{
IView view;
IModel model;

public Presenter(IView view, IModel model)
{
this.view = view;
this.model = model;

view.Shown += new EventHandler(view_Shown);
}

void view_Shown(object sender, EventArgs e)
{
view.OptionsForm.SpecialOptionsUserControl.CheckBox.DataBindings.Add("Checked", model, "IsOpened", false, DataSourceUpdateMode.OnPropertyChanged);

var dialogResult = view.OptionsForm.ShowDialog();
}
}`


which binds the model to the view when it's shown and opens an OptionsDialog. On the OptionsDialog is a UserControl with a Checkbox.
Now the following test should give a little bit of clearance about my problem:



[TestFixture]
public class PresenterTests
{
[Test]
public void ShouldBindCorrectly()
{
var stubView = MockRepository.GenerateStub<IView>();
var stubModel = MockRepository.GenerateStub<IModel>();

var presenterUnderTest = new Presenter(stubView, stubModel);

stubView.Stub(x => x.OptionsForm).Return(new OptionsForm());

stubView.Raise(x => x.Shown += null, this, EventArgs.Empty);
stubModel.AssertWasCalled(x => x.PropertyChanged += Arg<PropertyChangedEventHandler>.Is.Anything);
}
}


Ok, when I execute this test I get an error in line:
var dialogResult = view.OptionsForm.ShowDialog(); described above. Btw. I'm using Rhino Mocks 3.6 and NUnit 2.5.10.



Thanks for your help... (Please let me know if something is missing or could not be understood in my failure description.) Thanks.



Marco





Counting the number of first place scores with mysql

Ok, so I have the following database:



CREATE TABLE IF NOT EXISTS `highscores` (
`lid` int(11) NOT NULL,
`username` varchar(15) NOT NULL,
`score` int(16) NOT NULL,
PRIMARY KEY (`lid`,`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;


lid being the level id.



lets say I have the following values in the table:



lid, username,score

1,sam,15
1,joe,12
1,sue,6
1,josh,9
2,sam,8
2,joe,16
2,sue,4
3,sam,65
4,josh,87
4,sue,43
5,sam,12
5,sue,28
5,joe,29
and so on.


How would I create a query(or if required a set of queries) to get the following



sam has 3 high scores
joe has 2 high scores
josh has 1 high score


Thanks in advance.





Two simple [probably] coding questions

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<EditText
android:id="@+id/etNum"
android:layout_width="wrap_content"
android:layout_height="102dp"
android:hint="@string/Please enter a department number."
android:inputType="number"
/>

<EditText
android:id="@+id/etName"
android:layout_width="wrap_content"
android:layout_height="102dp"
android:hint="@string/Or enter a department name."
android:inputType="string"
/>

<requestFocus />


</LinearLayout>


** Q#1. Right at the last line, i get Multiple annotations found at this line:
- error: Error parsing XML: mismatched tag
- This text field does not specify an inputType
or a hint. Not sure what to do? **



package walmart.namespace;


import android.R;
import android.R.string;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class WalmartActivity extends Activity {
/** Called when the activity is first created. */

int department;
String name;
Button search;
TextView display;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


q#2: For the R.Layout.main, i have 'main cannot be resolved or is not a field'. I know i shouldn't use the import android.R in the imports, but it at least gets rid of the problem being the R. Any ideas on how to fix this?





REST web services with rails?

I am developing a application to connect with linkedin and pull user inforamtion, this application is done for both web and mobile, so we wanted to go for web services for connecting with linkedin and pull data.



i have googled but could not come to a conculsion, hopefully many of you might have done or experienced the same situation.



so please suggest me how to go about or where to start with.



since i am a new guy to ROR i could not alsoe decide the things fast.



Please help me.





nested tryCatch not catching error?

I have a function:



buggy <- function(...) {
tryCatch({
itWorked <- FALSE
stop("I don't like green eggs and ham!")
itWorked <- TRUE
}, finally = {
if ( itWorked )
return("I do, Sam I am")
else
return("I do not like them, Sam I am!")
})
}


Basically, buggy tries to do some calculations that may or may not succeed (determined by itWorked. The finally clause just makes sure that even if the calculation didn't work, something gets returned (in this case, "I do not like them, Sam I am!").



It works as expected:



> buggy()
Error in tryCatchList(expr, classes, parentenv, handlers) :
I don't like green eggs and ham!
[1] "I do not like them, Sam I am!"


Now I want to listen for errors in buggy():



tryCatch( buggy(), 
error=function(e) message('too bad! there was an error') )


However the error in buggy fails to raise an error in the surrounding tryCatch:



> tryCatch( buggy(), 
+ error=function(e) message('too bad! there was an error') )
[1] "I do not like them, Sam I am!"


I would expect this to say:



'too bad! there was an error'
[1] "I do not like them, Sam I am!"


Can anyone tell me why this does not work? Do I somehow need to 'raise' errors from within buggy?





dc.LineTo not drawing on OnPaint() unless I move the use the mouse and move the window out of view?

Unless I make "static CPaintDC dc(this);" the line won't draw? But this is not good as it will eventually error, also the graphics wont' keep on the screen.



Not sure what I am doing wrong



Note: I have a Timer that calls to this every 100ms(x and y are incremented)
thx



void CGraphicsDlg::OnPaint() 
{
CString s;
CPaintDC dc(this);// device context for painting

if (IsIconic())
{
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else if(x==0)
{
s.Format("%d", x);
edXa->SetWindowText(s);

dc.MoveTo(20,400);
}
else if (x>0){
s.Format("%d", x);
edXb->SetWindowText(s);

dc.LineTo(20 + x, 40); // doesn't draw unless I make "static CPaintDC dc(this);" <- which will error out
}
CDialog::OnPaint();
}

void CGraphicsDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent==1){
srand( (unsigned)time( NULL ) );

//y = rand() % 100;
y++;
x++;

OnPaint();
}
}




Why is it not recommended that you bundle require.js with your main.js file

When releasing to production, I concatenate and minify my JavaScript modules (using the AMD pattern) with the require.js optimizer.



The only thing I don't like is the fact that my default, this doesn't include require.js itself ... and so your users still have to make two HTTP calls (one for require, one for your compiled project).



Whilst require.js is small, I don't like making two calls because a) the first call is superfluous and b) it means I have to cache bust require.js as well as my project file (e.g. require.v2.js) note that we don't use querystring cache-busting as this has been shown to operate badly with proxies (i.e. they never cache the resource).






The documentation shows you HOW to bundle require.js into your project, but it also states




It is not recommended that you bundle require.js with your main.js file. Ideally require.js should be the same file contents wherever it is used.




My question is, when they say 'not recommended' - are we talking PURELY architecturally, i.e. can I be sure of having no side-effects?





Load forms without reloading forms services each time

we are migrating our Oracle Forms 10g application to APEX 4.1.



We need to include some Forms into APEX.



We have a PL/SQL function call_form, called from an APEX region, that simply writes the applet to load the form, passing the form name as parameter.



It works, but it always reload Forms services and it takes arround 10s each time, the Oracle Application Server Forms Services logo appears each time :





It is really a pain for users...



I thought it was because it was reloading jar files each time, so I have tried to use cache options when writting the applet (*cache_option*, *cache_archive*, ...) to cache the files in the JVM, without success.



I don't get the applet security warning each time, in the java cache viewer I can see the 4 jar files frmall.jar, frmwebutil.jar, FDialogPJC.jar and jacob.jar.



Here is the content of the Java console when calling a form, and then reloading the page, it seems it loads webutil 2 times :



 RegisterWebUtil - Loading WebUtil Version 10.1.2.3
proxyHost=null
proxyPort=0
connectMode=HTTP, native.
Forms Applet version is : 10.1.2.3
RegisterWebUtil - Loading WebUtil Version 10.1.2.3
proxyHost=null
proxyPort=0
connectMode=HTTP, native.
Forms Applet version is : 10.1.2.3


My JVM is 1.6.0_31.



The call_form procedure :



 procedure call_form(in_form_name in varchar2) is
begin
htp.p('
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://javadl-esd.sun.com/update/1.6.0/jinstall-6-windows-i586.cab" width="0" height="0" hspace="0" vspace="0">
<param name="type" value="application/x-java-applet">
<param name="codebase" value="http://myhost.ch/forms/java">
<param name="code" value="oracle.forms.webutil.common.RegisterWebUtil">
<param name="cache_option" value="Plugin">
<param name="cache_archive" value="frmwebutil.jar,jacob.jar">
<param name="cache_version" value="">
<comment>
<embed src="" pluginspage="https://java.sun.com/javase/downloads/index.jsp"
type="application/x-java-applet"
java_codebase="http://myhost.ch/forms/java"
java_code="oracle.forms.webutil.common.RegisterWebUtil"
cache_option="Plugin"
cache_archive="frmwebutil.jar,jacob.jar"
cache_version=""
width="0"
height="0"
hspace="0"
vspace="0">
</embed>
<noembed>Registration applet definition</noembed>
</comment>
</object>

<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://javadl-esd.sun.com/update/1.6.0/jinstall-6-windows-i586.cab" width="1015" height="745" hspace="0" vspace="0">
<param name="type" value="application/x-java-applet">
<param name="codebase" value="http://geode.cern.ch/forms/java">
<param name="code" value="oracle.forms.engine.Main">
<param name="cache_option" value="Plugin">
<param name="cache_archive" value="frmall.jar,FDialogPJC.jar,frmwebutil.jar,jacob.jar">
<param name="cache_version" value="">
<param name="serverURL" value="http://myhost.ch/forms/lservlet?ifcfs=http://myhost.ch/forms/frmservlet?config=myconfig&form='||in_form_name||'.fmx&acceptLanguage=fr">
<param name="networkRetries" value="0">
<param name="serverArgs" value="escapeParams=true module='||in_form_name||'.fmx userid= sso_userid=%20 sso_formsid=%25OID_FORMSID%25 sso_subDN= sso_usrDN= debug=no host= port= buffer_records=no debug_messages=no array=no obr=no query_only=no quiet=yes render=no record= tracegroup= log= term=">
<param name="separateFrame" value="False">
<param name="splashScreen" value="">
<param name="background" value="">
<param name="lookAndFeel" value="Oracle">
<param name="colorScheme" value="teal">
<param name="serverApp" value="default">
<param name="logo" value="">
<param name="imageBase" value="DocumentBase">
<param name="formsMessageListener" value="">
<param name="recordFileName" value="">
<param name="EndUserMonitoringEnabled" value="">
<param name="EndUserMonitoringURL" value="">
<param name="heartBeat" value="">
<param name="WebUtilLogging" value="off">
<param name="WebUtilLoggingDetail" value="normal">
<param name="WebUtilErrorMode" value="Alert">
<param name="WebUtilDispatchMonitorInterval" value="5">
<param name="WebUtilTrustInternal" value="true">
<param name="WebUtilMaxTransferSize" value="16384">
<comment>
<embed src="" pluginspage="https://java.sun.com/javase/downloads/index.jsp"
type="application/x-java-applet"
java_codebase="http://myhost.ch/forms/java"
java_code="oracle.forms.engine.Main"
cache_option="Plugin"
cache_archive="frmall.jar,FDialogPJC.jar,frmwebutil.jar,jacob.jar"
cache_version=""
width="1015"
height="745"
hspace="0"
vspace=""
serverURL="http://myhost.ch/forms/lservlet?ifcfs=http://myhost.ch/forms/frmservlet?config=myconfig&form='||in_form_name||'.fmx&acceptLanguage=fr"
networkRetries="0"
serverArgs="escapeParams=true module='||in_form_name||'.fmx userid= sso_userid=%20 sso_formsid=%25OID_FORMSID%25 sso_subDN= sso_usrDN= debug=no host= port= buffer_records=no debug_messages=no array=no obr=no query_only=no quiet=yes render=no record= tracegroup= log= term="
separateFrame="False"
splashScreen=""
background=""
lookAndFeel="Oracle"
colorScheme="teal"
serverApp="default"
logo=""
imageBase="DocumentBase"
recordFileName=""
EndUserMonitoringEnabled=""
EndUserMonitoringURL=""
heartBeat=""
WebUtilLogging="off"
WebUtilLoggingDetail="normal"
WebUtilErrormode="Alert"
WebUtilDispatchMonitorInterval="5"
WebUtilTrustInternal="true"
WebUtilMaxTransferSize="16384">
</embed>
<noembed>Forms applet definition</noembed>
</comment>
</object>
');
end;


Have you any idea on how I can prevent that ? Or do you think there is a better way to include Oracle Forms into APEX ?



Any help would be much appreciated.



Thanks.





FaceBook Messager always showing Error in Navigation Bar

From my app i uploaded video to amazon server and send that Url to facebook Friend.
But when friend uses Facebook Messager and click on that video link facebook Messager shows an Error in Navigation Bar.but if friend uses facebook app then above is not happen. Whats going wrong? Here is image for Error





Can't create Database Link to remote DB in Oracle-DB

We have a CRM system in our company, which uses an Oracle 11g database. It is developed by a third party vendor.



We do not have access to the server which runs the CRM system. But nevertheless, we have working DBA login data available to us (SYS user). It consists of:




  • server IP: 172.1.2.3

  • port: 1521

  • SID: abc

  • user: sys

  • password: *



We can use this to access the DB with Oracle SQL Developer 3.1 (Connections >> Properties)



Now parts of the data must be copied out of the CRM-database into an other Oracle database, which resides on another server.



To my understanding, I'd need to create a database link in my target database. I tried something like this:



CREATE PUBLIC DATABASE LINK xxx CONNECT TO sys IDENTIFIED BY ***** USING 'MYTNSENTRY'


My tnsnames.ora is as follows:



MYTNSENTRY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.1.2.3)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = abc)
)
)


.... and my listener.ora look like this:



MYLISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.1.2.3)(PORT=1521))
))
SID_LIST_MYLISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=MYTNSENTRY)
(ORACLE_HOME=C:\somepath) # path to Oracle home of target DB
(PROGRAM=extproc)))


Is PROGRAM=extproc the right choice? There are a couple of other programs to pick. I couldn't even start the listener with lsnrctl because it could not "verify the user" or something. Ironically, the listener-setup and database link to a MS SQL server work smoothly.



Now despite lacking some vital information about the CRM DB system, one can still connect to the DB in SQL Developer. Shouldn't it also be possible to make a connection between two Oracle DBs? Please help me with the setup and the creation of the database link.





Store console logging in Chrome in a persistent way

In a school project I am running some javascript that are inputted through the console window and run from there. This script manipulates the web page and outputs the results to the console.



PROBLEM: Keep / save these results in a persistant manner that does not go away on browser close, script malfunctioning / page reload, or if possible, pc crash.



I thought of using frameworks such as Log4js or jStorage (jQuery Storage), but as this is not my website I'm manipulating, I can't add code or markup to the page.



Is there any way to do this?



NOTE: It is not critical that I log the results to console, I could send them off somewhere or do something else with them if that makes it more easy to log.



Thanks.





Accessing Button properties from another form

I know this is a very common question, my problem is i have tried several methods and none of have worked for me.



What i have is two forms and what i need is for a button press on one form to set the enabled property of a button on my second form to true.



As i say i've tried multiple methods and none have worked so far.





html table value swapping

I have two tables created in html..
How could I move rows from one table to another table by choosing row via checkbox?
Can anyone give me a sample JS to do this. Thanks





The collection of questions increases with 10 questions, every time I resolve the quiz

I am writing a C# program to display a test of questions.
The test has 10 questions.
But the program doesn't want to follow the same algorithm if I select a new quiz with the help of



   private void newToolStripMenuItem_Click (object sender, EventArgs e) 


The quiz doesn't stop after 10 questions.It goes on, it repeats the questions and at a certain number of questions it blocks.



I stepped through the code,and I saw: when I resolve the quiz for the first time:questions.Count=10; when I resolve it for the second time: questions.Count=20; when I resolve it for the third time: questions.Count=30; Would you like to tell me how can I have questions.Count=10 for every quiz, please ?



Here is my code:



      public partial class Form3 : Form
{
int nr;
Collection<question> questions = new Collection<question>();

public class question
{
public bool displayed = false;
public string text;
}


//when I press a button from MenuStrip my quiz begin
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{ nr = 1;
button1.Enabled = true;//it's the next_question button

StreamReader sr = new StreamReader("quiz.txt");
while (!sr.EndOfStream)
{
question i = new question();
questions.Add(i);
}
sr.Close();
int x = r.Next(questions.Count);
textBox1.Text = questionText;
questions[x].displayed = true;
current_question=x;

}


private void button1_Click_1(object sender, EventArgs e)//it's the code for the
next_question button
{
if (nr >= questions.Count)
{
button1.Enabled = false;
}
else
{
int x;
do { x = r.Next(questions.Count); }
while (questions[x].displayed == true);
textBox1.Text = questionText;
questions[x].displayed= true;
nr++;
current_question = x;
}


}



I add that I tried to create



       Collection<question> questions = new Collection<question>()


for every quiz I resolve, putting this at the beginning of the



       private void newToolStripMenuItem_Click(object sender, EventArgs e) 


or at the end of my current quiz:



       if (nr >= questions.Count){ //here } 


None of these changes prevent the collection to increase with 10 questions.
Thank you!





SugarCRM: Conditionally hide / show edit and delete button in subpanel

I have created a custom module and related it to the leads module. It has certain custom columns such as "Type", "Notes" and so on.



The "Type" column can have 2 values i.e. "Call" and "Auto".



I want to show / hide the edit and delete buttons based on the value in the Type column. What's the best way to do this?
enter image description here





Show progress bar while downloading an Image in ASP.Net webform

I am working on a website which has article section and display image for all articles on Home Page and Article List Page. Some of these images are uploaded as png and have size greater than 11KB.



Suppose i display 20 articles on page with 20 image. sometimes image take time to download. I want to show progress bar for each image that will be downloaded. I have looked for it on net but i am not able to get the right stuff.



I would appreciate if some one can point me in the right direction.



I am developing this website in ASP.Net 4.0, C#. I am using simple ASP.Net image control to display image now i want to integrate with some jQuery function so that it will show some sort of Loading... effect till image is actually downloaded





bash script getting the value from a variable of the form var$[id]

This is the first time Im using a shell script ( #!/bin/sh ) and Ive been working my way through it reading tutorials and the like but Im stuck on this reading and writing values of a key..



Im trying to read in key=value pairs from a config file of the form



key1_begin=abc
key1_end=def

key2_begin=123
key2_end=jkl

.. and so on


I would like the user to pass in parameters to the script like



something.sh 1 x y z


where the first parameter would serve as an that is used to modify the appropriate keys. So after I have checked that the directory exists and the file exists I source it using



source config.cfg


I then save the id using ID=$1 and access the keys using



echo key${ID}_begin 


so a read to obtain the value of the key would be



echo key${ID}_begin = $[key${ID}_begin]


where I expect to get " key1_begin = abc " but instead keep getting " key1_begin = 0 ". The same command however seems to work work for numbers. For example using this command with an ID of 2 gives " key2_begin = 123 "



Could someone please point me in the right direction as to why this works fine for numbers but not alphabets?



And what do I use to change the value of the variable? I am currently using "eval" but this again seems to only work with numbers



[ ! -z $2 ] && eval key${ID}_end=$3


Would really appreciate any advice / pointers with this.\



Thank you





Using the stream insertion operator to read files

I happened to run across a code example for reading text from a file as follows:



int i; 
char *fileName = "text.txt";
ifstream fin(fileName);

while (fin >> i)
{
do something;
}


This code actually opens and reads space-delimited text, but I don't understand how it works. How does the file get opened without an "open" or "read" command? Is there a way to rewind back to the beginning of the file? I'm trying to create a dynamically allocated array, which I don't know how to do until after I've counted through the file for the number of scores.





In moblie devices' safari, <a href="#" onclick="return false"> doesn't work, why?

In moblie devices' safari, like iphone or ipad, <a href="#" onclick="return false"> doesn't prevent default behaviour, the page was still redirected to '#', why...?
Like these code:



<a href="#" onclick="return false" id="test_a">click me</a>

var elem = document.getElementById('test_a');
if (elem.addEventListener) {
elem.addEventListener('click', function() {
alert('clicked');
}, false);
} else {
elem.attachEvent('onclick', function() {
alert('clicked');
});
}?




getImageUrl() no returning any value in an external php

I am trying to display the image url in an external file. What I did is the following.



require_once '/var/www/html/app/Mage.php';
Mage::app();
$product = Mage:: getModel('catalog/product')->load(11);
echo $product->getImageUrl();


But the $product->getImageUrl() didnot return any value.
The file is located in the root folder where the index.php is present.
When I print the $product->getImage() , it displayed the image name.



Is the getImageUrl() not a default function in magento ?



when i used the function $Image = $product->getMediaConfig()->getMediaUrl($product->getData('image'));
the image url is displayed.





String literals vs String Object in Java

In java String can be created in 2 ways given below




  1. String foo="Test";

  2. String fooobj=new String("Test");



Everywhere it is mentioned about difference between these 2 ways of creating String. I want to know more about What are appropriate scenario's ,
where we should go for



  String foo="Test";


And when to go for



 String fooobj=new String("Test");  ?




Nothing is loaded into my jQuery dialog

Before I had the following jQuery:



var dialogDiv = "<div id='" + dialogId + "'></div>";

$(dialogDiv).load(href, function () {
...


It worked fine.



Now I changed a little bit like this:



var dialogDiv = "<div id='" + dialogId + "' class='modal hide fade'><div class='modal-body'><p class='body'></p></div></div>";

$('.modal-body p.body').load(href, function () {
...


Now nothing is loaded into my jQuery dialog. Any idea?



Thanks.





How do I convert this double foreach loop to just lambdas?

Is this there a way to these foreach loops just one lambda expression?



    private int getNextEventId()
{
int numOfEvents = 0;

foreach (MonthModel eventMonth in eventsForAllMonths)
{
foreach (DayModel eventDay in eventMonth.AllDays)
{
numOfEvents += eventDay.CalEvents.Count;
}
}

return numOfEvents + 1;
}




whats the most common mistake for having a CSS 100% height div?

Alrighty,



I'm going to try to explain what I have going on. Let me know if you need more information.



Basically, I have a div container, and I have it styled at height:100%; It will do 100% but it will only be 100% for the current browser/window size.



For example: if I maximize the browser, the container will do 100%, but if I scroll down, that container's height only goes as much as whatever the browser height was.



Another example: if I minimize the browser to a certain size and refresh the page, the container will go 100% again to the window size only. So if I maximize the browser, the height container will still be the same height has if the browser was minimize.



So if I have a long page, the container doesn't go all the way down to the page, the container only goes so far as the window's height size when the page loads.



I'm trying to get the container to go all the way 100% till the bottom of the page, even if I have a footer or header, the container should be 100% between the two.



So I'll try to post up the most relevant code:



body,html
{
display:block;
position:relative;
}
#container_100percent
{
overflow-x:hidden;
position:relative;
overflow-y:auto;
width:20%;
min-height:100%;
height:100%;
float:right;
}


<div>
<div id="container_100percent">
<!-- some stuff !-->
</div>
</div>




Grab Text-Node after find()-usage

I am using JQuery to show a tooltip-Box after clicking an image. So far, I can select the correct div(s) and then I can identify the correct sub-div which contains the text-node as well. Unfortunately I am not able to get the text node of the sub-div. What is wrong - I am getting 'null' after calling html() on currentDescriptionContainer? Thanks in advance!



var tooltipItems = jQuery('.tooltipContainer').length;
var i=0;
for (i=0; i<tooltipItems; i++){
jQuery('.tooltipContainer').eq(i).bind('click', function(){
var currentContainer = jQuery('.tooltipContainer').eq(i);
var currentDescriptionContainer = currentContainer.find('div');
var currentDescriptionText = currentDescriptionContainer.html();
console.log(currentDescriptionText);
showRendererToolTipForIpad(this, currentDescriptionText);
hideRenderedToolTipAfterTimeout();
});
}