Skip to content

Commit

Permalink
Fixes #156 - Make sure Piranha Embedded only allows JAR based projects (
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Apr 3, 2024
1 parent 004bc9b commit 90bef7f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
27 changes: 22 additions & 5 deletions src/main/java/start/StartBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@

import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.RequestScoped;
import jakarta.faces.component.UIInput;
import jakarta.faces.context.ExternalContext;
import jakarta.faces.context.FacesContext;
import jakarta.faces.event.AbortProcessingException;
import jakarta.faces.event.AjaxBehaviorEvent;
import jakarta.faces.model.SelectItem;
import jakarta.inject.Inject;
import jakarta.inject.Named;
Expand All @@ -46,7 +49,7 @@
@Named(value = "startBean")
@RequestScoped
public class StartBean implements Serializable {

/**
* Stores the selected example.
*/
Expand Down Expand Up @@ -101,10 +104,24 @@ public void download() {
}
facesContext.responseComplete();
}


/**
* Handle changing stack.
*
* @param event the event.
*/
public void changeStack(AjaxBehaviorEvent event) throws AbortProcessingException {
String value = event.getFacesContext().getExternalContext()
.getRequestParameterMap().get("form:stack");

if (value != null && value.equals("embedded")) {
model.setPackaging("jar");
}
}

/**
* Get the example.
*
*
* @return the example.
*/
public String getExample() {
Expand Down Expand Up @@ -184,10 +201,10 @@ public void initialize() {
public String getRuntime() {
return runtime;
}

/**
* Set the example.
*
*
* @param example the example.
*/
public void setExample(String example) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/start/StartModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class StartModel {
/**
* Stores the packaging.
*/
private String packaging = "war";
private String packaging;

/**
* Stores the stack.
Expand Down
4 changes: 3 additions & 1 deletion src/main/webapp/start.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
<h:outputLabel value="Packaging"/>: <h:selectOneRadio id="packagingRadio" value="#{startBean.model.packaging}">
<f:selectItems value="#{startBean.packagings}"/>
</h:selectOneRadio>
<h:outputLabel value="Stack"/>: <h:selectOneRadio id="stack" value="#{startBean.model.stack}">
<h:outputLabel value="Stack"/>:
<h:selectOneRadio id="stack" value="#{startBean.model.stack}">
<f:ajax execute="@form" render="@form" listener="#{startBean.changeStack}"/>
<f:selectItems value="#{startBean.stacks}"/>
</h:selectOneRadio>
<h:commandButton id="download" action="#{startBean.download}" value="Download"/>
Expand Down

0 comments on commit 90bef7f

Please sign in to comment.