diff --git a/.DS_Store b/.DS_Store index 9b96e41..c5ac295 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 56a6414..e99b5a3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ dist .faces-config.xml.jsfdia .project .classpath/PFSearchExpressions/ +.DS_Store diff --git a/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/AJAXBean.java b/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/AJAXBean.java index 7626c8b..b2c410c 100644 --- a/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/AJAXBean.java +++ b/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/AJAXBean.java @@ -27,6 +27,7 @@ public class AJAXBean { private boolean spinning=true; private boolean readOnly=false; private boolean disabled=true; + private boolean buttonRed=false; public boolean isSpinning() { return spinning; @@ -241,6 +242,22 @@ public String standardJSFAction() { report("Standard JSF action called"); return null; // "landingPage.jsf"; } + + public void facetListener(javax.faces.event.AjaxBehaviorEvent event) throws javax.faces.event.AbortProcessingException { + report("f:ajax listener called"); + } + + public void mouseOverListener(javax.faces.event.AjaxBehaviorEvent event) throws javax.faces.event.AbortProcessingException { + report("f:ajax mouseOver listener called"); + buttonRed=true; + } + + + public void mouseOutListener(javax.faces.event.AjaxBehaviorEvent event) throws javax.faces.event.AbortProcessingException { + report("f:ajax mouseOut listener called"); + buttonRed=false; + } + public void standardJSFActionListener() { report("Standard JSF actionlistener without parameters called"); @@ -248,4 +265,12 @@ public void standardJSFActionListener() { public void standardJSFActionListener(ActionEvent even) { report("Standard JSF actionlistener called"); } + + public boolean isButtonRed() { + return buttonRed; + } + + public void setButtonRed(boolean buttonRed) { + this.buttonRed = buttonRed; + } } diff --git a/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/ImageGallery.java b/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/ImageGallery.java index b51a833..ad6b480 100644 --- a/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/ImageGallery.java +++ b/AJAX/src/main/java/de/beyondjava/bootsfaces/examples/ImageGallery.java @@ -15,8 +15,8 @@ public class ImageGallery implements Serializable { @ManagedProperty("#{AJAXBean}") private AJAXBean ajaxBean; - - private String singleImage="http://www.11pictures.com/foto/stories/Camargue_2013_Nature/framedPreview.png"; + + private String singleImage = "http://www.11pictures.com/foto/stories/Camargue_2013_Nature/framedPreview.png"; private List images = new ArrayList() { { @@ -40,6 +40,13 @@ public class ImageGallery implements Serializable { private static final long serialVersionUID = 1L; }; + private List combinedImagePool = new ArrayList() { + { + addAll(images); + addAll(imagePool); + } + }; + public void setAjaxBean(AJAXBean ab) { this.ajaxBean = ab; } @@ -58,8 +65,15 @@ public void chooseAnotherImage(String image) { } public void chooseAnotherImage() { - int random = (int) Math.floor(Math.random() * imagePool.size()); - singleImage= imagePool.get(random); + while (true) { + int random = (int) Math.floor(Math.random() * imagePool.size()); + String newImage = imagePool.get(random); + if (!newImage.equals(singleImage)) { + singleImage = newImage; + break; + } + } + } public void chooseEveryImage() { diff --git a/AJAX/src/main/webapp/commandbutton2.xhtml b/AJAX/src/main/webapp/commandbutton2.xhtml index 9be47c4..5796207 100644 --- a/AJAX/src/main/webapp/commandbutton2.xhtml +++ b/AJAX/src/main/webapp/commandbutton2.xhtml @@ -8,8 +8,11 @@ - - + + + diff --git a/BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/jsf/Board.java b/BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/jsf/Board.java index 9619a03..9d56660 100644 --- a/BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/jsf/Board.java +++ b/BootsFacesChess/src/main/java/de/beyondjava/bootsfaces/chess/jsf/Board.java @@ -6,6 +6,7 @@ import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; +import javax.faces.event.ActionEvent; import de.beyondjava.bootsfaces.chess.Exceptions.EndOfGameException; import de.beyondjava.bootsfaces.chess.common.ChessConstants; @@ -27,8 +28,9 @@ public class Board implements Serializable { private List rows; - public Board() { + private boolean startOpponentsMove = false; + public Board() { redraw(); } @@ -49,13 +51,14 @@ public void setRows(List rows) { } public String getOpacity(int row, int column) { + if (startOpponentsMove) return "0.7"; if (!isPieceSelected) return "1.0"; if (selectedPieceColumn == column && selectedPieceRow == row) return "1.0"; if (chessboard.isMovePossible(selectedPieceRow, selectedPieceColumn, row, column)) return "1.0"; - return "0.7"; + return "0.8"; } public void onclick(int row, int column) { @@ -69,16 +72,10 @@ public void onclick(int row, int column) { chessboard = chessboard.moveChessPiece(selectedPieceRow, selectedPieceColumn, row, column, ChessConstants.W_QUEEN); - selectedPieceRow=0; - selectedPieceColumn=0; - try { - Move move = chessboard.findBestMove(); - chessboard = chessboard.moveChessPiece(move.fromRow, move.fromColumn, move.toRow, move.toColumn, - ChessConstants.W_QUEEN); - } catch (EndOfGameException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + selectedPieceRow = 0; + selectedPieceColumn = 0; + // opponentsMove(); + startOpponentsMove = true; } } else { @@ -94,4 +91,31 @@ public void onclick(int row, int column) { redraw(); } + public void opponentsMove(ActionEvent event) { + if (startOpponentsMove) { + startOpponentsMove = false; + try { + Move move = chessboard.findBestMove(); + chessboard = chessboard.moveChessPiece(move.fromRow, move.fromColumn, move.toRow, move.toColumn, + ChessConstants.W_QUEEN); + } catch (EndOfGameException e) { + e.printStackTrace(); + } + redraw(); + } + } + + public boolean isStartOpponentsMove() { + return startOpponentsMove; + } + + public void setStartOpponentsMove(boolean startOppenentsMove) { + this.startOpponentsMove = startOppenentsMove; + } + + public void flipSides(ActionEvent event) { + startOpponentsMove=true; + opponentsMove(event); + } + } diff --git a/BootsFacesChess/src/main/webapp/index.xhtml b/BootsFacesChess/src/main/webapp/index.xhtml index d294170..586693b 100644 --- a/BootsFacesChess/src/main/webapp/index.xhtml +++ b/BootsFacesChess/src/main/webapp/index.xhtml @@ -26,19 +26,25 @@ - - - + + + + - + + + +
-
-
+
+