Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private def notifyValueChange(
- containingDocument: XFormsContainingDocument,
- nodeInfo: NodeInfo,
- oldValue: String,
- newValue: String,
- isCalculate: Boolean,
- collector: XFormsEvent ⇒ Unit
- ) =
- Option(containingDocument.getInstanceForNode(nodeInfo)) match {
- case Some(modifiedInstance) ⇒
- // Tell the model about the value change
- try {
- val nodeName = nodeInfo.name
- var objectControl: XFormsObject = null
- try {
- objectControl = containingDocument.resolveObjectById(containingDocument.getEffectiveId, nodeName + "-control", null)
- } catch {
- case _: NullPointerException =>
- case e: Exception => e.printStackTrace(); XFormsServer.logger.warn(e.getMessage);
- }
- objectControl match {
- case selectControl: XFormsSelect1Control =>
- addLabelToNode(selectControl, newValue, nodeInfo)
- case valueComponentControl: XFormsValueComponentControl =>
- valueComponentControl.children.head match {
- case componentRootControl: XXFormsComponentRootControl =>
- componentRootControl.children.foreach {
- case wrappedSelectControl: XFormsSelect1Control =>
- addLabelToNode(wrappedSelectControl, newValue, nodeInfo)
- case _ =>
- }
- case _ =>
- }
- case _ =>
- }
- } catch {
- case e: Exception => e.printStackTrace(); XFormsServer.logger.warn(e.getMessage);
- }
- // rest of the method
- private def addLabelToNode(control: XFormsSelect1Control, newValue: String, nodeInfo: NodeInfo): Unit = {
- try {
- val name = control.element.getQName.getName
- if ("select1".equals(name)) {
- val label = control.getItemset.selectedItems(newValue).head.label.label
- XFormsAPI.ensureAttribute(nodeInfo, new QName("label", null, null), label)
- } else if ("select".equals(name)) {
- val stringList = new util.ArrayList[String]()
- val newValueArray = newValue.split(" ")
- newValueArray.foreach(
- v => {
- val item = control.getItemset.selectedItems(newValue).find(i => i.value == v).get
- stringList.add(item.label.label)
- }
- )
- val label = stringList.toArray.mkString(" ")
- XFormsAPI.ensureAttribute(nodeInfo, new QName("label", null, null), label)
- }
- } catch {
- case _: NoSuchElementException => XFormsAPI.ensureAttribute(nodeInfo, new QName("label", null, null), "")
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement