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.