-
-
Save hron84/e0609ad78db794a0ec81 to your computer and use it in GitHub Desktop.
JavaBlog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8' ?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" | |
xmlns:f="http://java.sun.com/jsf/core" | |
xmlns:ui="http://java.sun.com/jsf/facelets" | |
xmlns:h="http://java.sun.com/jsf/html"> | |
<h:head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<link href="./resources/css/default.css" rel="stylesheet" type="text/css" /> | |
<link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" /> | |
<title>Facelets Template</title> | |
</h:head> | |
<h:body> | |
<div id="top" class="top"> | |
<ui:insert name="top">Top</ui:insert> | |
</div> | |
<div id="content" class="center_content"> | |
<ui:insert name="content"> | |
<f:view> | |
<h:form> | |
<h1><h:outputText value="Create/Edit"/></h1> | |
<h:panelGrid columns="2"> | |
<h:outputLabel value="Id:" for="id" /> | |
<h:inputText id="id" value="#{article.details.id}" title="Id" required="true" requiredMessage="The Id field is required."/> | |
<h:outputLabel value="Title:" for="title" /> | |
<h:inputText id="title" value="#{article.details.title}" title="Title" required="true" requiredMessage="The Title field is required."/> | |
<h:outputLabel value="Body:" for="body" /> | |
<h:inputTextarea rows="4" cols="30" id="body" value="#{article.details.body}" title="Body" required="true" requiredMessage="The Body field is required."/> | |
<h:outputLabel value="CreatedAt:" for="createdAt" /> | |
<h:inputText id="createdAt" value="#{article.details.createdAt}" title="CreatedAt" required="true" requiredMessage="The CreatedAt field is required."> | |
<f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" /> | |
</h:inputText> | |
<h:outputLabel value="UpdatedAt:" for="updatedAt" /> | |
<h:inputText id="updatedAt" value="#{article.details.updatedAt}" title="UpdatedAt" required="true" requiredMessage="The UpdatedAt field is required."> | |
<f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" /> | |
</h:inputText> | |
</h:panelGrid> | |
</h:form> | |
</f:view> | |
</ui:insert> | |
</div> | |
</h:body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package me.hron.javablog.web; | |
import java.util.List; | |
import javax.ejb.EJB; | |
import javax.faces.bean.ManagedBean; | |
import javax.faces.bean.SessionScoped; | |
import me.hron.javablog.ejb.ArticleSessionBean; | |
import me.hron.javablog.entity.Article; | |
/** | |
* | |
* @author hron | |
*/ | |
@ManagedBean(name = "article") | |
@SessionScoped | |
public class ArticleMBean { | |
@EJB | |
private ArticleSessionBean articleSessionBean; | |
private Article article; | |
/** Creates a new instance of ArticleMBean */ | |
public ArticleMBean() { | |
} | |
public List<Article> getArticles() { | |
return articleSessionBean.listAll(); | |
} | |
public Article getDetails() { | |
return article; | |
} | |
public String showDetails(Article article) { | |
this.article = article; | |
return "DETAILS"; | |
} | |
public String update() { | |
article = articleSessionBean.update(article); | |
return "SAVED"; | |
} | |
public String list() { | |
return "LIST"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8'?> | |
<!-- =========== FULL CONFIGURATION FILE ================================== --> | |
<faces-config version="2.0" | |
xmlns="http://java.sun.com/xml/ns/javaee" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> | |
<navigation-rule> | |
<from-view-id>/index.xhtml</from-view-id> | |
<navigation-case> | |
<from-outcome>DETAILS</from-outcome> | |
<to-view-id>/article.xhtml</to-view-id> | |
</navigation-case> | |
</navigation-rule> | |
<navigation-rule> | |
<from-view-id>/article.xhtml</from-view-id> | |
<navigation-case> | |
<from-outcome>LIST</from-outcome> | |
<to-view-id>/index.xhtml</to-view-id> | |
</navigation-case> | |
</navigation-rule> | |
</faces-config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8' ?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" | |
xmlns:f="http://java.sun.com/jsf/core" | |
xmlns:ui="http://java.sun.com/jsf/facelets" | |
xmlns:h="http://java.sun.com/jsf/html"> | |
<h:head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<link href="./resources/css/default.css" rel="stylesheet" type="text/css" /> | |
<link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" /> | |
<title>Facelets Template</title> | |
</h:head> | |
<h:body> | |
<div id="top" class="top"> | |
<ui:insert name="top">My first Blog based on J2EE</ui:insert> | |
</div> | |
<div id="content" class="center_content"> | |
<ui:insert name="content"> | |
<f:view> | |
<h:form> | |
<h1><h:outputText value="Articles"/></h1> | |
<h:dataTable value="#{article.articles}" var="item"> | |
<h:column> | |
<f:facet name="header"> | |
<h:outputText value="ID"/> | |
</f:facet> | |
<h:outputText value="#{item.id}"/> | |
</h:column> | |
<h:column> | |
<f:facet name="header"> | |
<h:outputText value="Title"/> | |
</f:facet> | |
<h:outputText value="#{item.title}"/> | |
</h:column> | |
<h:column> | |
<f:facet name="header"> | |
<h:outputText value="Body"/> | |
</f:facet> | |
<h:outputText value="#{item.body}"/> | |
</h:column> | |
<h:column> | |
<f:facet name="header"> | |
<h:outputText value="Created At"/> | |
</f:facet> | |
<h:outputText value="#{item.createdAt}"> | |
<f:convertDateTime pattern="yyyy-MM-dd HH:mm" /> | |
</h:outputText> | |
</h:column> | |
<h:column> | |
<f:facet name="header"> | |
<h:outputText value="Updated At"/> | |
</f:facet> | |
<h:outputText value="#{item.updatedAt}"> | |
<f:convertDateTime pattern="yyyy-MM-dd HH:mm" /> | |
</h:outputText> | |
</h:column> | |
</h:dataTable> | |
</h:form> | |
</f:view> | |
</ui:insert> | |
</div> | |
</h:body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment