* Allow subskins of the currently rendered skin to be rendered using
relative skin names ("#subskinName") * Fix minor bug in subskin parsing.
This commit is contained in:
parent
4531ef6e4b
commit
3e20cadca1
3 changed files with 34 additions and 2 deletions
|
@ -113,6 +113,9 @@ public final class ResponseTrans extends Writer implements Serializable {
|
||||||
// the message digest used to generate composed digests for ETag headers
|
// the message digest used to generate composed digests for ETag headers
|
||||||
private transient MessageDigest digest;
|
private transient MessageDigest digest;
|
||||||
|
|
||||||
|
// the skin current or last rendered skin
|
||||||
|
private transient volatile Skin activeSkin;
|
||||||
|
|
||||||
// the application
|
// the application
|
||||||
Application app;
|
Application app;
|
||||||
|
|
||||||
|
@ -823,6 +826,25 @@ public final class ResponseTrans extends Writer implements Serializable {
|
||||||
skincache.put(id, skin);
|
skincache.put(id, skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the skin currently being rendered, returning the previously active skin.
|
||||||
|
* @param skin the new active skin
|
||||||
|
* @return the previously active skin
|
||||||
|
*/
|
||||||
|
public Skin switchActiveSkin(Skin skin) {
|
||||||
|
Skin previousSkin = activeSkin;
|
||||||
|
activeSkin = skin;
|
||||||
|
return previousSkin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the skin currently being rendered, or none.
|
||||||
|
* @return the currently active skin
|
||||||
|
*/
|
||||||
|
public Skin getActiveSkin() {
|
||||||
|
return activeSkin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a cookie.
|
* Set a cookie.
|
||||||
*
|
*
|
||||||
|
|
|
@ -256,6 +256,7 @@ public final class Skin {
|
||||||
// register param object, remember previous one to reset afterwards
|
// register param object, remember previous one to reset afterwards
|
||||||
Map handlers = res.getMacroHandlers();
|
Map handlers = res.getMacroHandlers();
|
||||||
Object previousParam = handlers.put("param", paramObject);
|
Object previousParam = handlers.put("param", paramObject);
|
||||||
|
Skin previousSkin = res.switchActiveSkin(parentSkin);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int written = offset;
|
int written = offset;
|
||||||
|
@ -279,6 +280,7 @@ public final class Skin {
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
reval.skinDepth--;
|
reval.skinDepth--;
|
||||||
|
res.switchActiveSkin(previousSkin);
|
||||||
if (previousParam == null) {
|
if (previousParam == null) {
|
||||||
handlers.remove("param");
|
handlers.remove("param");
|
||||||
} else {
|
} else {
|
||||||
|
@ -422,6 +424,7 @@ public final class Skin {
|
||||||
}
|
}
|
||||||
b.append(source[i]);
|
b.append(source[i]);
|
||||||
escape = false;
|
escape = false;
|
||||||
|
break;
|
||||||
|
|
||||||
case '|':
|
case '|':
|
||||||
|
|
||||||
|
|
|
@ -596,10 +596,17 @@ public class RhinoEngine implements ScriptingEngine {
|
||||||
* caching.
|
* caching.
|
||||||
*/
|
*/
|
||||||
public Skin getSkin(String protoName, String skinName) throws IOException {
|
public Skin getSkin(String protoName, String skinName) throws IOException {
|
||||||
SkinKey key = new SkinKey(protoName, skinName);
|
Skin skin;
|
||||||
ResponseTrans res = getResponse();
|
ResponseTrans res = getResponse();
|
||||||
|
if (skinName.startsWith("#")) {
|
||||||
|
// evaluate relative subskin name against currently rendering skin
|
||||||
|
skin = res.getActiveSkin();
|
||||||
|
return skin == null ?
|
||||||
|
null : skin.getSubskin(skinName.substring(1));
|
||||||
|
}
|
||||||
|
|
||||||
Skin skin = res.getCachedSkin(key);
|
SkinKey key = new SkinKey(protoName, skinName);
|
||||||
|
skin = res.getCachedSkin(key);
|
||||||
|
|
||||||
if (skin == null) {
|
if (skin == null) {
|
||||||
// retrieve res.skinpath, an array of objects that tell us where to look for skins
|
// retrieve res.skinpath, an array of objects that tell us where to look for skins
|
||||||
|
|
Loading…
Add table
Reference in a new issue