在我的命令obj myCmd中有一个Map
$scope.setTitle = function(table_title)
{
// table_title = "Table 1 is the title";
table_title_g = table_title ;
var table_db_ref_copy = new Firebase("https://glaring-torch-3069.firebaseio.com/tables/"); //database ref for the table
var str_table_db_ref_copy = "https://glaring-torch-3069.firebaseio.com/tables/";
var table_number = table_title_g.charAt(6);
var str_table = "table";
var str_table_final = str_table.concat(table_number);// try str_table = str_table.concat(table_number)
var str_players = "/players";
var str_table_db_ref_players = str_table_db_ref_copy.concat(str_table_final);
var str_table_db_ref_players_fb = new Firebase(str_table_db_ref_players);
var players_at_table_snapshot = null;
var get_players_at_table =
function(players_at_table_snapshot_actual)
{
players_at_table_snapshot = null;
players_at_table_snapshot = players_at_table_snapshot_actual;
};
str_table_db_ref_players_fb.on('value',get_players_at_table);
str_table_db_ref_players_fb.off('value',get_players_at_table);
var players_at_table_data = players_at_table_snapshot.val();
player_one_v = players_at_table_data.players.player1;
player_two_v = players_at_table_data.players.player2;
player_three_v = players_at_table_data.players.player3;
player_four_v = players_at_table_data.players.player4;
};
var temp_ind = 0;
var intvId = 0;
$scope.gameEngine_v = function()
{
// if(temp_ind == 1)
// {
// intvId = setInterval(gameEngine, 3000);
intvId = setTimeout(gameEngine, 3000);
// gameEngine(temp_ind);
// }
// if(temp_ind == 0)
// {
// clearInterval(intvId);
// }
};
$scope.gameEngine_v_stp = function()
{
// clearInterval(intvId);
clearTimeout(intvId);
// gameEngine(temp_ind);
};
//tables_snapshot https://glaring-torch-3069.firebaseio.com/tables
var gameEngine = function(){
// if(game_s_var == 1){
var table_db_ref = new Firebase("https://glaring-torch-3069.firebaseio.com/tables/"); //database ref for the table
players_db_ref = new Firebase("https://glaring-torch-3069.firebaseio.com/players/"); //database ref for the list of potential players
str_players_db_ref = "https://glaring-torch-3069.firebaseio.com/players/";
// Basic usage of .once() to read the data located at firebaseRef.
counter = 0;
var tables_snapshot = null;
var players_snapshot = null;
var get_tables_snapshot =
function(datasnapshot_tables)
{
tables_snapshot = null;
tables_snapshot = datasnapshot_tables;
};
var get_players_snapshot =
function(datasnapshot_players)
{
players_snapshot = null;
players_snapshot = datasnapshot_players;
};
var msg = null;
var onComplete = function(error) {
msg = null;
if (error) {
msg = "Failed Synchronization";
} else {
msg = "Success";
}
};
table_db_ref.on('value',get_tables_snapshot);
table_db_ref.off('value',get_tables_snapshot);
tables_snapshot.forEach(
function(childSnapShot)
{
var key = childSnapShot.key();
var data = childSnapShot.val();
var str_1 = "https://glaring-torch-3069.firebaseio.com/tables/";
var str_2 = "/players";
var str_3 = str_1.concat(key,str_2);
var t_mode = data.mode;
var players = new Firebase(str_3);//path for players at the table
players_db_ref.on('value',get_players_snapshot);
players_db_ref.off('value',get_players_snapshot);
var count = 0;
var flag = 0;
if(t_mode == 'singles' && flag == 0)
{
players_snapshot.forEach(
function(player_snaphot)
{
count = count + 1;
var player_data = player_snaphot.val();
var player_key = player_snaphot.key();
var str_currentPlayer = str_players_db_ref.concat(player_key);//holds the url of the current player
var currentPlayer_ref = new Firebase(str_currentPlayer);
var player_emp_id = player_data.emp_id;
if(count == 1)
{
players.update(
{
player1:player_emp_id
}
);
currentPlayer_ref.remove(onComplete);
var str_test = 'i am here !!';
}
else if (count == 2)
{
players.update(
{
player2:player_emp_id
}
);
currentPlayer_ref.remove(onComplete);
}
else
{
flag = 1;
// return true; // to go out of forEach loop
}
}
);
// var d = setTimeout(gameEngine(1), 3000);
}
count = 0 ;
if(t_mode == 'doubles' && flag == 0)
{
players_snapshot.forEach(
function(player_snaphot)
{
count = count + 1;
var player_data = player_snaphot.val();
var player_key = player_snaphot.key();
var player_emp_id = player_data.emp_id;
if(count == 1)
{
players.update({ player1:player_emp_id });
currentPlayer_ref.remove(onComplete);
}
else if (count == 2)
{
players.update({ player2:player_emp_id });
currentPlayer_ref.remove(onComplete);
}
else if (count == 3)
{
players.update({ player3:player_emp_id });
currentPlayer_ref.remove(onComplete);
}
else if (count == 4)
{
players.update({ player4:player_emp_id });
currentPlayer_ref.remove(onComplete);
}
else
{
flag = 1; // to go out of forEach loop
}
}
);
}// end of 'doubles' mode elseif
}
);
// }
};
// var d = setTimeout(gameEngine(1), 3000);
我有一个使用这个命令obj作为其命令的jsp'
private Map<Long, List<String>> map = new HashMap<Long, List<String>>();
现在我想将多个选择绑定到地图中的列表
<form:form commandName="myCmd">
但我得到了<form:select multiple="true" path="map[${id}]">
我该如何解决这个问题?
答案 0 :(得分:0)
你需要这样做:
<form:select multiple="true" path="selectedValue">
<form:options items="${map[${id}]}"></form:options>
</form:select>
其中,selectedValue
是myCmd
Class中的String变量。