[rhmessaging-commits] rhmessaging commits: r2290 - mgmt/trunk/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Tue Aug 12 19:36:51 EDT 2008
Author: eallen
Date: 2008-08-12 19:36:51 -0400 (Tue, 12 Aug 2008)
New Revision: 2290
Modified:
mgmt/trunk/cumin/python/cumin/binding.py
mgmt/trunk/cumin/python/cumin/binding.strings
Log:
Now with improved All/Active handling to preserve the form values
Modified: mgmt/trunk/cumin/python/cumin/binding.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/binding.py 2008-08-12 23:35:49 UTC (rev 2289)
+++ mgmt/trunk/cumin/python/cumin/binding.py 2008-08-12 23:36:51 UTC (rev 2290)
@@ -1,8 +1,8 @@
from cumin.exchange import ExchangeInfo
-from cumin.util import sorted_by, is_active
+from cumin.util import sorted_by
from cumin.widgets import StateSwitch
-from formats import fmt_shorten
-from wooly import Template, Writer, Attribute
+from formats import *
+from wooly import Template, Writer, Attribute, Parameter
from wooly.forms import FormInput, FormField
from wooly.parameters import DictParameter
from wooly.resources import StringCatalog
@@ -235,9 +235,10 @@
self.add_state("c", "Active")
self.add_state("a", "All")
- def render_href(self, session):
- pass
-
+ def render_item_link(self, session, state):
+ path = state == "a" and "state_all" or "state_active"
+ return super(ExchangeState, self).render_item_link(session, state, id=path)
+
def is_all(self, session):
return self.get(session) == "a"
@@ -251,6 +252,10 @@
self.dict_param = DictParameter(app, "exchange")
self.add_parameter(self.dict_param)
form.add_form_parameter(self.dict_param)
+
+ self.phase = Parameter(app, "phase")
+ self.add_parameter(self.phase)
+ form.add_form_parameter(self.phase)
self.direct_input = DirectExchangeInput(app, "direct", form)
self.add_child(self.direct_input)
@@ -272,9 +277,17 @@
self.binding_errors = self.Errors(self, "binding_errors")
self.add_attribute(self.binding_errors)
- self.__state = ExchangeState(app, "phase")
- self.add_child(self.__state)
+ self.state = ExchangeState(app, "phase")
+ self.add_child(self.state)
+ def render_phase_path(self, session, vhost):
+ # the hidden input phase MUST be rendered before the stateswitch
+ phase = self.phase.get(session)
+ if phase:
+ self.state.set(session, phase)
+
+ return self.phase.path
+
def get_args(self, session):
broker = self.get_parent_named("broker")
reg = broker.get_object(session)
@@ -294,7 +307,7 @@
writer = Writer()
for exchange in sortedExchanges:
if ExchangeInfo.is_builtin(exchange) or \
- not (self.__state.is_active(session) and not is_active(exchange)):
+ not (self.state.is_active(session) and not is_active(exchange)):
# instance_key gives us a unique path for each exchange
# we will be rendering
instance_key = self.dict_param.get_instance_key(str(exchange.id))
@@ -318,6 +331,9 @@
return writer.to_string()
+ def post_process(self, session):
+ self.dict_param.clear()
+
def get_binding_errors(self, session, queue_name):
form_binding_info = self.process_binding_info(session, queue_name)
@@ -356,16 +372,6 @@
berrs.setdefault(name, dict())
berrs[name]["xquery"] = ["Missing xquery"]
- if len(berrs):
- # Tell dictionary to clear out any
- # values the next time the page is submitted
- # before it starts adding new entries.
- # This is needed because checkboxes don't
- # send a blank value when they are cleared.
- self.dict_param.set_clear_on_add()
- else:
- self.dict_param.clear()
-
return (len(berrs), form_binding_info)
def process_binding_info(self, session, queue_name):
Modified: mgmt/trunk/cumin/python/cumin/binding.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/binding.strings 2008-08-12 23:35:49 UTC (rev 2289)
+++ mgmt/trunk/cumin/python/cumin/binding.strings 2008-08-12 23:36:51 UTC (rev 2290)
@@ -132,9 +132,25 @@
headers_extra.style.display = display;
}
+function toggle_phase(state) {
+ var phase_state = document.getElementById("phase_state")
+ if (phase_state) {
+ phase_state.value = state;
+ document.forms[0].submit()
+ }
+ return false;
+}
+function attachPhase() {
+ if (document.getElementById("state_all"))
+ document.getElementById("state_all").onclick = function() { return toggle_phase("a") }
+ if (document.getElementById("state_active"))
+ document.getElementById("state_active").onclick = function() { return toggle_phase("c") }
+}
+addEvent(window, "load", attachPhase);
[ExchangeKeysField.html]
<div class="field">
+ <input id="phase_state" type="hidden" name="{phase_path}" value="" />
<div class="rfloat">{phase}</div>
<div class="title">{title}</div>
<div class="rclear"> </div>
More information about the rhmessaging-commits
mailing list