Hello This Is Rp Guild Forums
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in
Welcome To RpBloodline Forum->ATTENTION!! Please Dont Used Your Character Email,Login,Password Here,THIS IS NOT ALLOWED!!! For Your Protection Charcter Please Used Another Email To Register Here Thanks.. RP Jump3r

Share | 
 

 [stripes / google app-engine] GodsWar Quest-List

View previous topic View next topic Go down 
AuthorMessage
kikugalanet

avatar

Posts : 38
Join date : 2010-04-07

PostSubject: [stripes / google app-engine] GodsWar Quest-List   Wed Apr 07, 2010 9:55 pm

you want to get hit? with a crapload of code?
here I go:

Code:

<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<head></head>
<html>
<body>
<h1><a href="/de/hans/questlist/Easy.action">Enter</a></h1></body>
</html>

haha, that was only the index.jsp

but wait. there is more... a lot more...
but first. If you got no idea what stripes is:
it's basically a framework which helps you build web-applications.
With stripes you dont need freaking servlets anymore and no xml-hell. Just great, isn't it?

It finds the classes/methods to direct a request to and get a response from with the help of your code... that's right, you have to watch how you code your stuff.
All methods/classes that should be visible to stripes have to be
a) programmed after the bean-pattern and
b) declared as public

if you want to know more, go and read it up:
http://www.stripesframework.org/display/stripes/Home

This isn't (or, shouldn't be) a beginners tutorial.
I'll just present my code and comment here and there a bit.



So, you remember the code above?
Code:

<a href="/de/hans/questlist/Easy.action">Enter</a>

this link directs to my main ActionBean.
after definition the url consists of:
Code:

myProject/my/packet/myClass.action

so, myClass (in my case it's "Easy") is in reality "EasyActionBean"

and here it is:
Code:

package de.hans.questlist;

import java.util.ArrayList;
import java.util.List;

import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.Resolution;

public class EasyActionBean implements ActionBean {
ActionBeanContext actionBeanContext;
String VIEW = "/WEB-INF/jsp/test.jsp";
String msg;
List<?> minLvl = new ArrayList<Object>();
List<?> map = new ArrayList<Object>();
String[] onlyTp = { "true", "false" };
private String minReqLvl="1";
private String giverMap="1";
private String onlyTpBool="true";
private List<String> quests = new ArrayList<String>();
private GetNodes gn = new GetNodes();
private GatherResponseStuff gatherRespondeStuff = new GatherResponseStuff();
private MapNamesAndMapIdConversion caseForMapIds = new MapNamesAndMapIdConversion();

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
this.msg = msg;
}


public Resolution getNew() {
return new ForwardResolution(VIEW);
}

@DefaultHandler
public Resolution getResult() {
setQuests(gatherRespondeStuff.filterQuests(caseForMapIds.returnId(giverMap), minReqLvl, onlyTpBool));
return new ForwardResolution(VIEW);
}
@Override
public ActionBeanContext getContext() {
// TODO Auto-generated method stub
return actionBeanContext;
}
@Override
public void setContext(ActionBeanContext actionBeanContext) {
this.actionBeanContext = actionBeanContext;

}

public void setMinLvl(String arr) {
this.msg = arr;
}

public List<?> getMinLvl() {

minLvl = gn.populateDropDownBox("/@MinLevel", true);
return minLvl;
}

public void setMap(List<?> map) {
this.map = map;
}

public List<?> getMap() {

List<String> temp = new ArrayList();
for(Object i:gn.populateDropDownBox("/@GiverMapID", true)){
temp.add(caseForMapIds.returnMap((Integer)i));
}
map=temp;

return map;
}

public void setOnlyTp(String[] onlyTp) {
this.onlyTp = onlyTp;
}

public String[] getOnlyTp() {
return onlyTp;
}

public void setMinReqLvl(String minReqLvl) {
this.minReqLvl = minReqLvl;
}

public String getMinReqLvl() {
return minReqLvl;
}

public void setGiverMap(String giverMap) {
this.giverMap = giverMap;
}

public String getGiverMap() {
return giverMap;
}

public void setOnlyTpBool(String onlyTpBool) {
this.onlyTpBool = onlyTpBool;
}

public String getOnlyTpBool() {
return onlyTpBool;
}

public void setQuests(List<String> quests) {
this.quests = quests;
}

public List<String> getQuests() {
return quests;
}

}

you see? many getter/setter methods that are public and can thereby be called from our jsp.

One thing that should be mentioned that there is one Method that is different:

Code:

@DefaultHandler
public Resolution getResult() {
setQuests(gatherRespondeStuff.filterQuests(caseForMapIds.returnId(giverMap), minReqLvl, onlyTpBool));
return new ForwardResolution(VIEW);
}

this method is called when no other method in the request is specified that returns a Resolution.
In other words, this Method sends a redirect to
Code:

String VIEW = "/WEB-INF/jsp/test.jsp";

and here is our test.jsp
Code:

<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld"%>

<!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">
<head>
<link rel="stylesheet" href="/style.css" type="text/css">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Quest Database</title>
</head>
<body style="background: #100;">
<table ALIGN="center">
<tr>
<td><s:form action="${actionBean.class}">

<div class="main">
<table>
<tr align="center">
<td>
<table>
<tr align="center">
<td>MinLvl</td>
<td>Map</td>
<td>only with TP</td>
</tr>


<tr align="center">

<td><s:select name="minReqLvl">
<s:options-collection collection="${actionBean.minLvl}" />
</s:select></td>
<td><s:select name="giverMap">
<s:options-collection collection="${actionBean.map}" />
</s:select></td>
<td><s:select name="onlyTpBool">
<s:options-collection collection="${actionBean.onlyTp}" />
</s:select></td>

</tr>
</td>
</table>
</tr>
<tr align="center">
<td><s:submit name="getResult" value="get Quests" /></td>
</tr>
<c:forEach items="${actionBean.quests}" var="q">
<tr onMouseover="this.bgColor='#999'"
onMouseout="this.bgColor='#ddd'">
<td align="center">${q}</td>
</tr>
</c:forEach>
</table>
</br>


</div>
<div class="clear"></div>
</s:form></td>
</tr>
</table>
</body>
</html>

since everything is in a stripes form-tag with the action attribute
Code:

<s:form action="/de/hans/questlist/Easy.action">

every request/response cycle is directed from and to my EasyActionBean.

go look up which Methods are getting called from
Code:

${actionBean.minLvl}
${actionBean.map}
${actionBean.onlyTp}
${actionBean.quests}

and take a whild guess what this part does:
Code:

<s:submit name="getResult" value="get Quests" />

and this does nothing else as to receive a collection of objects and fill a dropdown-box with them.
Code:

<s:options-collection..
Back to top Go down
View user profile
 
[stripes / google app-engine] GodsWar Quest-List
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Arena Quest List
» A guide for MH2(dos)
» Full Moon Quests
» Event quest list:
» Online MH1 Missions

Permissions in this forum:You cannot reply to topics in this forum
Welcome To RpUnion Forum :: General Discusstion :: C/C++/C# Discussion-
Jump to: