假设您在控制器级别将Book对象存储在flash.book中,那么您的第二个页面可能如下所示:
<html>
<head>
<g:javascript library="prototype" />
<g:javascript>
function showLast(selectedId) {
if (selectedId) {
$$('#books option[value=' + selectedId + "]")[0].selected = true;
} else {
$('books').selectedIndex = 0;
}
};
Event.observe(window, 'load', init, false);
function init() {
showLast(${flash?.book?.id});
}
</g:javascript>
</head>
<body>
<g:select id="books" name="id"
from="${Book.list()}"
value="title"
optionValue="title"
optionKey="id"
/>
</body>
</html>