2
Contributors
7
Replies
9
Views
8 Years
Discussion Span
Last Post by emilio
0

i used a bean object like this:

<jsp:useBean id="game" class="Classes.Game" scope="session" />
 <jsp:setProperty name="game" property="*" />

in the calss Game there is a property that is an array of enum type that i defined.
i want to access the arrays values which are from the enum type.

0

I presume you implemented some setter and getter methods in your "Game" bean. Therefore you should be able to get them with something like game.getMyEnumArray(numPosition)

0

yes but i want to compare values inside array.
like this:

numPosition[i] == Enum.player1 ;

i cannot do this because the enums defenition in in Game calss
and the jsp does not recognize this kind of Enum.

in class Game i defined :

enum State
    {
      empty,player1,player2;   
    }

public class GameBoard {
    
    private final int N = 8;
    protected State[][] Board = new State[N][N];
}

i can get Board with getBoard, but i cannot compare it's values.

0

i imported my enum to the jsp page and it's working now.
thanks for the help.

1

my jsp project includes class Game:

public class Game {
    
    private final int N = 8;
    public State[][] Board = new State[N][N];
    public enum State
    {
      empty,player1,player2;   
    }
}

in my jsp page i wrote :

<%@page import="Classes.Game.State" %>.
<jsp:useBean id="game" class="Classes.Game" scope="session" />
 <jsp:setProperty name="game" property="*" />

<% if (game.getBoard()[i][j-1]==State.player1) { %>
                                      <td><img src="b.JPG" heigh="40" width="40"></td>
                                      <% } %>

the if statement is working due to the import line

Votes + Comments
Thank you for share solution
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.