logo
down
shadow

ui:composition and statesaving in JSF


ui:composition and statesaving in JSF

Content Index :

ui:composition and statesaving in JSF
Tag : jsf-2 , By : boonchew
Date : December 01 2020, 04:55 PM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Branching function composition: composition version of if/cond?


Tag : clojure , By : smbrant
Date : March 29 2020, 07:55 AM
should help you out Well there could be many such composition pattern you can come up and ask why this isn't in the core language. The reason is obvious, it is not feasible. The core of the language provide you all the constructs to build such patterns. These sort of features are more of a contrib kind of thing rather than core of the language.
As far as implementation is concerned it would as simple as something shown below:
(defn condf [& args]
  (let [chain (partition 2 args)]
    (fn [& params]
      (first (for [[p f] chain :when (or (= :else p) (apply p params))]
                (apply f params))))))

(def my-func (condf string? clojure.string/trim 
                  vector? (partial apply str)
                  :else identity))

(my-func "Ankur ") ==> "Ankur"
(my-func [1 2 3]) ==> "123"
(my-func '(1 2 3)) ==> (1 2 3)

aborting Windows IME composition / clearing composition string


Tag : windows , By : Shawazi
Date : March 29 2020, 07:55 AM
To fix this issue I'm having trouble aborting IME composition on Windows. , You may clear composition with this:
ImmSetCompositionStringW(himc, SCS_SETSTR, L"", sizeof(wchar_t), L"", sizeof(wchar_t));
ImmReleaseContext(hwnd, himc);
ImmGetContext(hwnd);

Does Kotlin support or have future plan for Interface Composition similar to Protocol Composition in Swift?


Tag : swift , By : Star Gryphon
Date : March 29 2020, 07:55 AM
around this issue You can not explicitly define intersection types in Kotlin, but you can use generic type constraints to achieve it in a function parameter. Like this:
interface Named {
    val name: String
}

interface Aged {
    val age: Int
}

fun <T> wishHappyBirthday(celebrator: T) where T : Named, T : Aged {
    println("Happy birthday, ${celebrator.name}, you're ${celebrator.age}!")
}

How to access root context from a composition function in Vue Composition API / Vue 3.0 + TypeScript?


Tag : typescript , By : kameel
Date : March 29 2020, 07:55 AM
this one helps. Well, I soon found out a proper example on that same RFC site. But decided to share my examples here.
The RFC site doesn't include examples in TypeScript at the moment, for clarity's sake I presume. As this new way of writing Vue 3.0 components and composition functions (as a replacement to Mixins) takes a bit of getting used to.
// File: @/util/notify.ts
import { SetupContext } from '@vue/composition-api';

export function useNotify(context: SetupContext) {
  const notifyError = (title: string, msg: string) => {
    context.root.$bvToast.toast(msg, {
      title,
      variant: 'danger'
    });
  };

  return { notifyError};
}

export default useNotify;
// Use in your functional component:
import { createComponent, SetupContext } from '@vue/composition-api';

import { useNotify} from '@/util/notify';

export default createComponent({
  name: 'MyFailingComponent',
  setup(props: any, context: SetupContext) {
    const { notifyError } = useNotify(context);

    notifyError('Request error', 'There was an error processing your request, please try again later.');

    return {};
  }
});
// File: @/util/notify.ts
import { SetupContext } from '@vue/composition-api';

export function useNotify({ context, defaultTitle = 'Hey!' }: { context: SetupContext, defaultTitle?: string }) {
  const notifyError = (msg: string, title?: string) => {
    context.root.$bvToast.toast(msg, {
      title: title || defaultTitle,
      variant: 'danger',
    });
  };

  return {
    notifyError,
  };
}

export default useNotify;

// Usage like:
const { notifyError } = useNotify({ context });
// Or
const { notifyError } = useNotify({ context, defaultTitle: 'Hey there' });

java.lang.IllegalStateException: Composition requires an active composition context (Android Jetpack Compose)


Tag : android , By : clifton anderson
Date : March 29 2020, 07:55 AM
like below fixes the issue Creates a data class for the state model, and it does not have to be marked with the @Model annotation. The initial state itself is created inside the @Composable function using + state. The visibility of the dialog is determined by the visible property of the model obtained by calling the value property. This property can also be set to a new immutable object, as happens in the onClick of both buttons. The first hides itself, the second - closes the dialogue. The dialog can be reopened by clicking on the Ok button, defined inside the same @Composable function.
When trying to make a state outside this function, an error occurs:
 data class DialogVisibleModel(val visible: Boolean, val dismissPushed: Boolean = false)
    ...
 @Composable
 fun homeScreenCompose() {

   Column {
        SideBySideAlertDialogSample()
   }

 }

@Composable
fun SideBySideAlertDialogSample() {
    val openDialog = +state { DialogVisibleModel(false) }

    Button(text = "Ok", onClick = { openDialog.value = DialogVisibleModel(true) })

    if (openDialog.value.visible) {
        AlertDialog(
            onCloseRequest = {
                // Because we are not setting openDialog.value to false here,
                // the user can close this dialog only via one of the buttons we provide.
            },
            title = {
                Text(text = "Title")
            },
            text = {
                Text("This area typically contains the supportive text" +
                        " which presents the details regarding the Dialog's purpose.")
            },
            confirmButton = {
                Button("Confirm", onClick = {
                    openDialog.value = DialogVisibleModel(false)
                })
            },
            dismissButton = {
                if (!openDialog.value.dismissPushed)
                    Button("Dismiss", onClick = {
                        openDialog.value = DialogVisibleModel(true, true)
                    })
                else {
                    //hidden
                }
            },
            buttonLayout = AlertDialogButtonLayout.SideBySide
        )
    }
}
shadow
Privacy Policy - Terms - Contact Us © scrbit.com