Wednesday, May 23, 2012

GWT - DialogBox.center() doesn't work correctly

There's a table with buttons on my page. There're so much buttons, that I have a scroller to scroll down my table.



Button "onClick" generates a dialog box with scrollpanel, content and a button to close this dialog box. I center it using DialogBox.center(). When I press, let's say the first button in a table, dialog box appears strictly in the center.... but when I scroll down the page and press button in the bottom of my table, my DialogBox still appears in the "old" center...almost above my view. It simply doesn't move down according to my scrollbar position.
I tried to change setPopupPosition(), setPopupPositionAndShow() and so on, but it didn't help.



Is there any ideas what is wrong? Here is some code of my dialog box:



public class MyDialogBox extends DialogBox {

public MyDialogBox(final String caption, final String text) {
setText("Caption: " + caption);

VerticalPanel inner = new VerticalPanel();
Label msg = new Label(text);

Button ok = new Button("Close");
ok.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
MessageTextBox.this.hide();
}
});

inner.add(msg);
ScrollPanel scrollbar = new ScrollPanel(inner);
scrollbar.setSize("640", "480");
VerticalPanel outer = new VerticalPanel();
outer.add(scrollbar);
outer.add(ok);
setWidget(outer);
}
}


And here is how my button call it:



VerticalPanel mainPanel ... //MainPanel with a lot different elements, it contains panel with buttons
VerticalPanel panel ... //Panel with buttons
panel.setViewButtonHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
MyDialogBox dialogBox = new MyDialogBox("Caption", "Some text");
dialogBox.center();
}
});
mainPanel.add(panel);




How to add icon in button when slide down in jquery

enter image description hereI did some code for jquery sliding-toggle div but for now i want to adding icon in button when sliding down i want to show a small arrow icon bottom of the open content button. when i click again on open content button that icon want to remove.



go through the following path for see the code.
jsfiddle link



<div id="btn-div">Open content</div>
<div id="content-div">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
<br class="clear"/>
</div>




body{
font:12px/18px Arial;
color:white;
}
#btn-div{
background:blue;
padding:10px;
font-size:14px;
line-height:20px;
color:white;
width:100px;
}
#content-div{
background:#106DCD;
display:none;
padding:10px;
}
.clear{
clear:both;
}?




 $('#btn-div').live('click', function() {
$("#content-div").slideToggle("slow");
});?


?





Summing over lists in python - is there a better way?

Is there a more sensible way of doing this? I want to make a new list by summing over the indices of a lot of other lists. I'm fairly new to programming and this seems like a very clunky method!



list1 = [1,2,3,4,5]
list2 = [1,1,1,4,1]
list3 = [1,22,3,1,5]
list4 = [1,2,5,4,5]
...
list100 = [4,5,6,7,8]

i = 0
while i < len(list1):
mynewlist[i] = list1[i]+list2[i]+list3[i]+list4[i]+...list100[i]
i = i+1




How can I pass an int value as the LinkText for and ActionLink

@Html.ActionLink((string)item.NUM, "Building", "Property", new {id=item.STRAP, bldNum = item.NUM }, null)


This throws a Yellow screen of death.




Cannot convert type 'int' to 'string'




However, this works.



@Html.ActionLink("HI", "Building", "Property", new {id=item.STRAP, bldNum = item.NUM }, null)




How do UNIQUE indexes work on multiple columns?

just a quick question: how exactly does the unique index check the if the field(s) is(are) unique when added on multiple columns?



For example, if I add a UNIQUE index on the email,password columns, will the index check if:




  1. Is email unique AND is password unique, or

  2. The combination of email,password is unique, as in, it would allow u1@mail.com, 123 and u2@mail.com, 123



Apologies if my thoughts seem abrupt here, I'm having difficulty in expressing them today for some reason. Thanks in advance!





jenkins complains host key verification failure although the key was generated

Error:



Fetching upstream changes from git@github.com:....../.........git
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Error performing command: git fetch -t git@github.com:....../......git +refs/heads/:refs/remotes/origin/
Command "git fetch -t git@github.com:...../......git +refs/heads/:refs/remotes/origin/" returned status code 128: Host key verification failed.
fatal: The remote end hung up unexpectedly



My comments:



1> I found that jenkins build fails when it executes ; git fetch -t git@github.com:...../......git +refs/heads/:refs/remotes/origin/



2> Executed the folleing to ensure the key works: -
ssh -T git@github.com
Hi [username]! You've successfully authenticated, but GitHub does not provide shell access.



But when I pasted the same command on the command line it executes it successfully: weird!



Any help ASAP is much appreciated .





Backbone views design for standard menubar / detail pages mobile UI

I'm building a mobile web app and have been struggling with the design and wiring of my backbone views.



Let me illustrate what I would like to achieve.



enter image description here



As you can see, the image above identifies few UI components:




  • Toolbar view with back, search and menu button

  • Tabbed view with lists

  • Detail view

  • Menu view



Some notes on the behavior:




  • Tapping on the menu button overlays and animates the menu.

  • The list and detail views are permanently accessible with hashtags



For now I have created views for the toolbar, menu, list and detail. But obviously there has to be some interaction between views and I'm not sure how to handle it.



Problems to solve:




  1. Do I render all views when going to detail or list? If not, how to update the toolbar and handle that relationship

  2. How to remember which tab was shown when going to detail from say tab 2 and go back to list. Remembering the visible tab with hashtags is not an option because just switching between tabs should not be remembered.



I've been looking into tbranyen layoutmanager but it still seems to assume complete isolated views.





Single CSS file for all @media vs separate CSS file for each @media

If I have all media types in single CSS file, for example



the below is a content of style.css



@media only screen and (min-width: 480px) {
/* Style adjustments for viewports 480px and over go here */

}

@media only screen and (min-width: 768px) {
/* Style adjustments for viewports 768px and over go here */

}

@media print {
/* Style adjustments for Print go here */
}


Will browser download download the CSS part of @media only screen and (min-width: 480px) and @media print if I open the file on a device which has min-width: 768px?



or browser will download whole css on the device even if it will be never used on same device. For example the devices which has maximum width of 480px in both orientation will never need the CSS code of written for the device with greater then 480px width or height even if the CSS is cached. it will be no use?



Is using separate CSS file for each media best for performance?



Which can increase the performance, HTTP request or a separate and only required code needed for device?





CSS inline-block IE9

I currently have a search "button" that I made sit on the side of a textbox, as shown in the picture below, this renders fine in chrome and firefox.



enter image description here



In IE9 it renders like this.



IE Render



Has anyone ran into a similar problem? How can I get around this?



The CSS for the search button is:



    .txtSearchBtn
{
display: inline-block;
width: 16px;
height: 16px;
position: relative;
left: -20px;
top: 5px;
cursor: hand;
cursor: pointer;
background-image: url(../Images/magnifier.png);
}




How to restart application at specefic time

I have a service and some activity for that , I want whole application will restart at specific time like (03:00 pm), do you know any way to to do this , so at 3AM , the whole app restart ?



thanks





ActionScript Vector casting inconsistency?

When a Vector is casted like this...



var v1:Vector.<String> = new Vector.<String>();
v1.push("foo");

var v2:Vector.<Object> = Vector.<Object>(v1)

v1.push("bar");

trace(v1); //foo,bar
trace(v2); //foo


... a copy of the Vector is created, as you can see in the trace output.



But when you change line 3 to...



var v2:Vector.<*> = Vector.<*>(v1)


... no copy is created, both v1 and v2 point to the same object, trace outputs will both be "foo,bar".



Why that? Shouldn't there somehow be a consistent behaviour?





ASP.NET: Get Value of Previous Page Controll's

My page consists of 4 tab(Using a Jquery Accordian).



Tab 1.) User selects Device Make and Model(Default.aspx)



Tab 2.)User Confirms Our Buyback price(GetPrice.aspx is loaded into Tab2)



Tab 3.)User Enters Contact information(Default.aspx)



Tab 4.)Confirmation Page Displaying Users Information(Conf.aspx is loaded into Tab3)



The problem arises because I need my CodeBehind(on Conf.aspx) to have access to the user's contact information. If I passed the value's through query string, it would enable users to tamper with it and insert erroneous information into my database. Keep in mind, all of this is done WITHOUT postback.



So I need:



1.)A way to tamper-proof the Query String(keep in my the query string would consist of a Phone number,email address,state,city,zip,etc)



2.)A simple way to grab the values of the previous field(Get the values of the contact page on Default.aspx, from the final page, conf.aspx)



Sorry for the long block of text, any help would be appreciated.





Core-Data willSave: method

I have an attribute modificationDate in my Entity A. I want to set it's value whenever NSManagedObject is saved. However, if i try to do that in NSManagedObject willSave: method, i get an error:



*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to process pending changes before save.  The context is still dirty after 100 attempts.  Typically this recursive dirtying is caused by a bad validation method, -willSave, or notification handler.' ***


So, i'm wondering, what's the best way to set the value of modificationDate?





duplicated rows which have duplicated primary key in a view

i have i view and i mappe it like this



@Id
@Column(name = "IDBQ", precision = 5, scale = 0)
public Integer getIdbq() {
return this.idbq;
}

public void setIdbq(Integer idbq) {
this.idbq = idbq;
}


@Column(name = "ID", precision = 22, scale = 0)
public Integer getId() {
return this.id;
}

public void setId(Integer id) {
this.id = id;
}

@Column(name = "NOM_CLIENT", length = 100)
public String getNomClient() {
return this.nomClient;
}

public void setNomClient(String nomClient) {
this.nomClient = nomClient;
}

@Column(name = "PRENOM_CLIENT", length = 30)
public String getPrenomClient() {
return this.prenomClient;
}


and beacause it's a view the primary key IDBQ in many rows is duplicated.
the probleme when i make a request hql from hibernate it return : duplicated rows which have duplicated Id -> IDBQ





JSF page does not properly set object attributes

Simple question from a beginner at JSF:



I have very simple JSF form:



<h:form>
<p>#{messages.loginTextfieldUsername}</p>
<h:inputText value="#{userServiceImpl.user.name}" />

<p>#{messages.loginTextfieldPassword}</p>
<h:inputSecret value="#{userServiceImpl.user.password}" />

<h:commandButton value="#{messages.loginButtonLogin}" action="#{userServiceImpl.authenticateUser}" />
</h:form>


The userServiceImpl class is:



@Named
@RequestScoped
public class UserServiceImpl implements UserService {

private UserSession userSession;
private User user;

@Inject
public UserServiceImpl(UserSession userSession) {
this.userSession = userSession;
}

@PostConstruct
public void prepareService() {
user = new User();
}

@Override
public View authenticateUser() {
userSession.setLoggedUser(user);
return View.MAIN;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}


}



My goal is pretty simple: when the user hits the login button, I want to authenticate the user.



The problem is:
When the authenticate method is called, the User attributes are null. I debugged the application and the getUser method is called and the values are properly set, but at some point (which I did not find [yet]) before the authenticateUser is called the User attributes are set to null...



I'm aware that this is a pretty basic question... but are you able to point out where my mistake is?



Thanks.





Using Qt with eclipse, #include <QSqlDatabase> leads to file not found

So I have started a new Qt console project;



everything so far has been working fine. I have eclipse set up with the integration, but i'm not actually using it, i have just included the relevant Qt directories so that my #include <QtGui> calls work.



These have all worked perfectly so far.



i can compile it either using eclipse's build option, or by doing



qmake -project
qmake
make


from the command line. Both work.



the include statements i have; are:



#include <QtGui>
#include <QApplication>


In two different files.



If i add anotherone though, i.e. #include <QSqldatabase> then eclipse recognises the include, and lets me initialise new variables, and use the QSqlDatabase classes. Everything seems fine - see here - eclipse screenshot



When i build the project though, it decides it can't see the files even though they are all there, see them here in the terminal too. And then eclipse puts red lines everywhere.



If i go into the directory, and attempt to do it all via the terminal, using the qmake -project; qmake; make then i get the same errors.



If however, I go into the .pro file created by qmake -project, and add the line QT += sql, and then do qmake; make, then all is fine and it works.



Why is qmake -project leaving out these files from the project file? I'd really rather not have to go in and manually add that line every time I build it...





Run .NET app that targets 3.0 on a machine that has only Frameworks 2.0 and 4.0

Could anyone advise on whether an app that targets .NET 3.0 will work on a users machine that has .NET 2.0 and 4.0 but not 3.0? The installers for 3.0 and 3.5 crash on this particular machine.





CSS Nesting Problem - Reading container information

This problem comes up from time to time when I work with CSS, here is the issue I face.



My current code is:



<div class="entry">
<div>
<blockquote><p>quoted text</p></blockquote>
</div>
</div>


In my css, I have:



.entry p {margin: 10px}
blockquote {stuff}
blockquote p {margin: 0px}


I would think the paragraph inside the blockquote would read from 'blockquote p', but instead it takes the margin: 10px from '.entry p'.



Why does it read from 'entry p' instead of 'blockquote p'?





How to center WPF CheckBox within GridViewColumn?

How to center WPF CheckBox within GridViewColumn?



<GridViewColumn   Width="60" Header="Success">
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Path=IsSuccess}">
</CheckBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>





UPDATES:



This solution works fine but it destroys Expression Dark theme for cells...
(I don't know for know how to fix it...)



<ListView Name="HistoryTable" Width="783" VerticalAlignment="Stretch"   VerticalContentAlignment="Top" Height="195">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<Style TargetType="{x:Type CheckBox}" x:Key="DataGridCheckBox">
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="IsEnabled" Value="False" />
<Setter Property="Margin" Value="4" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Width" Value="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type GridViewColumn}},Path=ActualWidth}" />
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Filename}" Width="140" Header="{lex:LocTextExtension Key=Name, Dict=Resources, Assembly=PreShow.Player}" />
<GridViewColumn Width="60" Header="{lex:LocTextExtension Key=Success, Dict=Resources, Assembly=PreShow.Player}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<DockPanel HorizontalAlignment="Center">
<CheckBox IsChecked="{Binding Path=IsSuccess}" Style="{StaticResource DataGridCheckBox}">
</CheckBox>
</DockPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>


enter image description here





Forward requests coming into port 80, for a particular link, to port 8080 locally

I have 2 web forms, one coded using Java Servlets on glassfish (port 8080) and another using PHP on apache(port 80). But my office ITdept is refusing to open port 8080 to outside traffic.
How do I set up Apache such that requests coming in for the form with the servlets are directed to port 8080?
Thanks
TX
PS: Im using wamp





Which String method: "contains" or "indexOf > -1"?

Which of the following ways is an efficient way of determining substring containment?



if (str.indexOf("/") > -1)


or



if (str.contains("/")) 




Adding 2checkout to WordPress s2member Pro (PHP)

I am trying to enable the option of allowing my customers to make payments using 2checkout while taking care of the subscriptions and content protection using WordPress with s2member PRO.



Reading a few very basic guides ( http://www.primothemes.com/forums/viewtopic.php?f=36&t=3154 ) and ( http://www.primothemes.com/forums/viewtopic.php?t=6314&p=53139 ) gives little clue as to how to actually create this integration.



I can most likely figure out most of it, but I need help with things like, what files do I need to create, edit, etc. What configuration changes do I need to make in s2member to allow the new gateway to show up in the control panel? Or is there an easier "behind the scenes" way of doing it? Basically I need help in getting it started. It seems like such a simple upgrade and I'm upset that the developers have not already created this option... please help.





Arabic characters issue

I have some problems with displaying some Arabic text in my iPhone application. When I am displaying it on a UILabel, it shows like ?????? ????? ?????? The string comes from server as XML, I parse it and display on a UILabel. I dont know this is due to a problem in iPhone or from Server side.




  • I want to know how can I determine the string coming from server is having correct encoding and is a valid Arabic characters.


  • Is it suffice to print value each character and check it lies between Arabic Unicode characters. (Like ASCII value of character A is 65 and that of Z is 90. So a value 70 must be a ASCII character).


  • In server the string is encoded with UTF8 encoding. And server program written in c#. What is the write encoding method to transfer Arabic text from server to iPhone?


  • Do I need to use other fonts to display Arabic characters correctly.


  • Is there any XML file with Arabic content in Internet, from where I can parse and display arabic text correctly?




Thanks in advance..



EDIT:



When I NSLogged XML data I got same ???? ???? ??? characters.



EDIT



See a XML styled data that I got in console.



<CB_SEC_COMP>
<SC_COMP_ID>9999</SC_COMP_ID>
<SCA_LONG_NAME>???? ????? ?????????? ????? ?????????</SCA_LONG_NAME>
<SCE_LONG_NAME>CHINA SECURITY &amp; SURVEILLANCE TECHNOLOGY, INC.</SCE_LONG_NAME>
<SCA_SHORT_NAME>???? ????? ?????????</SCA_SHORT_NAME>
<SCE_SHORT_NAME>CHINA SECURITY &amp; SUR</SCE_SHORT_NAME>
<SC_MRK_CODE>9</SC_MRK_CODE>
<SC_SEC_CODE>86</SC_SEC_CODE>
<SC_STATUS>Y</SC_STATUS>
<TICKER_ID>CSR</TICKER_ID>
<SC_MRK_TYPE_CODE>0001</SC_MRK_TYPE_CODE>
<SC_EXCHANGE>DFM</SC_EXCHANGE>
<CUR_CODE>AED</CUR_CODE>
</CB_SEC_COMP>




Javascript passing object as function parameter

I'm quite new to javascript, so maybe it's a silly error.
I created an object like the follwing:



function objA(){
this.prop1;
this.prop2;
this.prop3;
this.func1=function(){
alert('func1');
}
this.func2=function(){
alert('func2');
}
}


I now have a function where I want to pass the object:



var foo=new objA;

function test(foo){....}


The problem is that when I call test(), I get the functions in objA (objA.func1 and objA.func2) executed.
I would like just to get the properties value of objA.
I have to use another function and an array, fill the array with the properties of objA and then pass the array:



var arrayA={}

function fillArray(data){
arrayA.prop1=data.prop1;
arrayA.prop2=data.prop2;
arrayA.prop3=data.prop3;
}

function test(arrayA){....}


Is it the only way or I'm doing something wrong ?





android merging 2 images

i'm working on this for hours and can't solve it.
i want to merge 2 images in an XML file - so this will be the basic xml file for my shape.
i want this shape to include a png which is the frame, and a png which is a picture inside a frame. that picture will change dynamically.



i've tried to use tag and to build my shape, but when i'm including it to my main xml file it fails because i can use merge only as root.
try to did the same with , and still didn't get what i wanted...



what can i do to be able to merge these 2 pngs, and to be able to set the inner png position inside the frame png??