Thursday, 3 October 2013

Changing progressbar level

Changing progressbar level

I have a simple activity that is suppose display a progress bar with
different fill levels. This activity with the progress bar is display
after a student undertake a practice test on my mobile application. So the
progess bar would show if the student passed showing all blue with the
color filling it. if it is an average performance. The color is half
filled in green. If it is a poor performance the color is completely red
with a slight color fill.
My little code to set fill color is below but it not working
if(grade.equals("passed")){
setProgress(100);
}
else{
setProgress(50);
}

Wednesday, 2 October 2013

how to undo hijacked files in clearcase?

how to undo hijacked files in clearcase?

I have this strange hijacked file in my snapshot view. when I undo it, it
doesn't go away. Is there a way to un-hijack it. I already tried
undo-hijacked but didn't work. I should see .keep file if it unhijacked
but didn't see any. Also tried to check out and uncheck out but this file
still remains as hijacked.
Thanks for any help !!

Multiple Variable Assignment from Single Hash Ruby

Multiple Variable Assignment from Single Hash Ruby

Hello All This seems like a day 1 question, And I feel like I've had it
working before, but for some reason I'm at a loss. But I'm trying to have
an Array assign a value to two variables.
test = "hello, my,name,is,dog,how,are,you"
testsplit = test.split ","
testsplit.each do |x,y|
puts y
end
I would think that it would print my is how you
but it appears the values only get passed to x and not to y. When i run
this code y comes back as empty.

How to pass an ID from a repeater row to a nested gridview?

How to pass an ID from a repeater row to a nested gridview?

QUESTION
If you have a gridview inside a repeater, how do you pass a primary key ID
to the gridview where the primary key relates to the repeaters item
template row?
I am currently attempting to do this by using a hiddenfield that contains
the PK and a control parameter to detect it and bind it to the gridview.
CURRENT ERROR
Could not find control 'hidPK' in ControlParameter 'PK'.
ABBREVIATED CODE
<asp:Repeater ID="rpt" RunAt="Server">
<ItemTemplate>
<asp:HiddenField ID="hidPK" runat="server" Value='<%#
DataBinder.Eval(Container.DataItem, "PK") %>'/>
<asp:GridView DataSourceID="sqlSource"></asp:GridView>
</ItemTemplate>
</asp:Repeater>
<asp:SqlDataSource ID="sqlSource" RunAt="Server"
SelectCommand="spPopulateGridview" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ControlParameter Type="Int32" Name="PK" DefaultValue="0"
ControlID="hidPK"/>
</SelectParameters>
</asp:SqlDataSource>

Tuesday, 1 October 2013

Spring Data REST: Silent failure when adding entity relationship

Spring Data REST: Silent failure when adding entity relationship

Fellow Spring Data REST enthusiasts, I am running my Spring Data REST 1.1
application, and I am attempting use curl to add an entity relationship
using the "text/uri-list" Content-type, as described in the link:
Example-API-usage-with-curl.
curl -v -d "http://localhost:8080/simplemvc/rest/enemies/3" -H
"Content-Type: text/uri-list"
http://localhost:8080/simplemvc/rest/heroes/1/defeatedEnemies
Unfortunately, although the server returns "201 Created", the body
contains an empty JSON object, and the entity relationship does not get
created:
{
"links" : [ ],
"content" : [ ]
}
I would expect to see a SQL UPDATE being executed, but analyzing the SQL
reveals that only SELECT statements occur:
Hibernate: select hero0_.HERO_ID as HERO1_1_0_, hero0_.name as name2_1_0_
from HERO hero0_ where hero0_.HERO_ID=?
Hibernate: select defeateden0_.HERO_ID as HERO4_1_1_,
defeateden0_.ENEMY_ID as ENEMY1_0_1_, defeateden0_.ENEMY_ID as
ENEMY1_0_0_, defeateden0_.description as descript2_0_0_,
defeateden0_.HERO_ID as HERO4_0_0_, defeateden0_.name as name3_0_0_ from
ENEMY defeateden0_ where defeateden0_.HERO_ID=?
Hibernate: select enemy0_.ENEMY_ID as ENEMY1_0_1_, enemy0_.description as
descript2_0_1_, enemy0_.HERO_ID as HERO4_0_1_, enemy0_.name as name3_0_1_,
hero1_.HERO_ID as HERO1_1_0_, hero1_.name as name2_1_0_ from ENEMY enemy0_
left outer join HERO hero1_ on enemy0_.HERO_ID=hero1_.HERO_ID where
enemy0_.ENEMY_ID=?
Interestingly, if I "manually" add a relationship by executing a SQL
statement in my database client:
UPDATE ENEMY SET HERO_ID = 1 WHERE ENEMY_ID = 1;
and then execute the curl statement:
curl -v -H "Accept: application/json"
http://localhost:8080/simplemvc/rest/heroes/1/defeatedEnemies
I get a JSON representation that demonstrates -- via hypermedia links --
that Spring Data REST recognizes the one-to-many relationship between the
Hero and Enemy entities:
{
"links" : [ ],
"content" : [ {
"name" : "Red Ghost",
"description" : "Likes to chase",
"links" : [ {
"rel" : "self",
"href" : "http://localhost:8080/simplemvc/rest/enemies/1"
}, {
"rel" : "enemy.enemy.hero",
"href" : "http://localhost:8080/simplemvc/rest/enemies/1/hero"
} ]
} ]
}
This is an existing Spring MVC app to which Spring Data REST is being
added, using the following article as a guide:
Adding-Spring-Data-REST-to-an-existing-Spring-MVC-Application
I have tried using both H2 and MySQL databases with the same result. Below
are my JPA entities, Spring Data JPA Repositories, application context,
and web.xml:
Hero.java
@Entity
@Table(name = "HERO")
public class Hero {
@TableGenerator(
name="heroGen",
table="ID_GEN",
pkColumnName="GEN_KEY",
valueColumnName="GEN_VALUE",
pkColumnValue="HERO_ID",
allocationSize=1)
@Id
@GeneratedValue(strategy=TABLE, generator="heroGen")
@Column(name = "HERO_ID")
private Integer id;
@Column
private String name;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy
= "hero")
private Set<Enemy> defeatedEnemies;
...
}
Enemy.java
@Entity
@Table(name = "ENEMY")
public class Enemy {
@TableGenerator(name="enemyGen",
table="ID_GEN",
pkColumnName="GEN_KEY",
valueColumnName="GEN_VALUE",
pkColumnValue="ENEMY_ID",
allocationSize=1)
@Id
@GeneratedValue(strategy=TABLE, generator="enemyGen")
@Column(name="ENEMY_ID")
private Integer id;
@Column
private String name;
@Column
private String description;
@ManyToOne
@JoinColumn(name = "HERO_ID")
private Hero hero;
...
}
HeroRepository.java
@RestResource(path = "heroes")
public interface HeroRepository extends CrudRepository<Hero, Integer> {
}
EnemyRepository.java
@RestResource(path = "enemies")
public interface EnemyRepository extends CrudRepository<Enemy, Integer> {
}
root-context.xml includes:
<jpa:repositories base-package="com.simple.simplemvc.repositories" />
<bean id="restConfig"
class="org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration"/>
web.xml includes:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<servlet>
<servlet-name>rest-dispatcher</servlet-name>
<servlet-class>org.springframework.data.rest.webmvc.RepositoryRestDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest-dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Any ideas? Thanks!

On success of ajax post, how to send a POST request with JQuery .load() method

On success of ajax post, how to send a POST request with JQuery .load()
method

After a successful Ajax post, I would like the template associated with
POST in the handler to be rendered with JQuery's .load() method. The GET
request keeps getting called after a successful POST ...so the template
associated with GET is getting rendered instead of the one associate with
POST. Thanks for any hints you can give.
Javascript:
$(function() {
$(".topic_submit").click(function() {
var topic = $("#topic").val();
refresh = 'false'
$.ajax({
type: "POST",
url: "/mentorlist",
data: {'topic': topic},
success: function(dataString) {
$('#mentor_list').load('/mentorlist');
console.log('**mentor_list div updated via ajax.**');
}
});
return true;
});
});
HTML Form:
<form id="topic_search_form" name="topic_search_form" action="">
Topic: <input id ="topic" type="text" name="topic" size="60"
placeholder="Search by Keyword" />
<input type="submit" class="topic_submit" name="topic_submit"
value="Search" >

Camera not working but camera light is on when trying to use it

Camera not working but camera light is on when trying to use it

I can't use my camera in Google hangout, I can share desktop in Google
Hangout and it works fine but camera never works, it looks like this

I have also tried using Cheese and i also just get a back screen. The
light beside my camera is on when using Google Hangout or Cheese.
Does anyone know how to fix this?