Passing classes in with Slots to vue components - class

I have a vue component
<Student></Student>
I want to change the style based on if they are an undergrad or postgrad.
I know I can pass in a prop and use this value to assign a dynamic class or use it in a computed prop.
<Student type="'postGrad'"></Student>
But can I do this with slots and assign a class or is there a better way to use props to achieve this?
<Student>
<slot name="type">PostGrad/slot>
</Student>
I have always used props but feel I could be missing a good technique with slots.

Just try to add class
<Student class="myClass">
<slot name="type">PostGrad/slot>
</Student>

Related

Expression Binding for Property in SAPUI5

I'm trying to set the property of a control using another control's property. In my case, I have one <sap.m.Select> and a <sap.m.Input>. The visible of <sap.m.Input> will depend on the selectedItem of the <sap.m.Select>. IMO, there is an available approach using Expression binding in XML View but I don't know how. Any suggestion?
You can use two way binding so that both properties are binding expressions over the same property in the model.
So you can create a JSON model for example and put there a property called selectedItem. The binding of the properties should be: on select selectedItem={mymodel>selectedItem} and on input visible={parts: [{path: "mymodel>selectedItem"}], formatter: function (selectedItem) {<your manipulation>} }.
You can do that with JavaScript and with XML view. In XML view you should reference to a formatter method in the controller.

How to set documentation for custom components?

How can I set up the documentation for our custom components and actions so that they will be displayed at the IDE? The same goes for the variable names of these classes. Now the will be displayed like variableName instead of Variable Name.
Thanks in advance
Hardie
This is done with BeanInfo classes.
Look at samples/customCode/src/ManyFeaturesActionBeanInfo.java for an example. That BeanInfo class describes the properties for the class defined in ManyFeaturesAction.java.

How to use Java constantns as a parameter in a Struts 2 OGNL tag

I am ussing to recover a property from an object User in the session. The following expression works correctly:
<s:property value="#session.ATRB_SESSION_USER.getAttribute('ATTRIBUTE_USER_NAME')"/>
but those strings ATRB_SESSION_USER and ATTRIBUTE_USER_NAME are constatns defined in a class. How can I use the constant instead of the string? I'd like to do something like this
<s:property value="#session.<%=Constants.ATRB_SESSION_USER%>.getAttribute(<%=Constants.ATTRIBUTE_USER_NAME%>)"/>
Anyone knows how can I do that?
TIA
You can use #class#field OGNL syntax to refer to static fields. The class name in #class should be fully qualified.

Using Generic Types with MVC2 Templates

I have a model class that is a generic type. I would like to create a custom editor template that would display it (and put it in the Shared folder).
How can I do that?
I can't figure out how to name it so that MVC2 would pick it up over the generic template.
Additionally I am wondering if there is a way to explicitly specify which template a top-level class should use (like you can do with a property using UIHint attribute). Is there a way to override the functionality that picks the templates based on the class name?
Please help.
The easiest way is to accomplish #1 is to specify the template name when displaying the model, as the second parameter:
<%= Html.DisplayFor(m => m.GenericList, "DisplayList")%>
The handling is generics isn't very good in MVC2. The source code says:
// TODO: Make better string names for generic types
So, when rendering a list, it look for a template named List`1 be default to render it, if you don't specify another name.
On the second point, you would would do the same as #1. Specify the templatename or use UIHint when rendering the item.

How do I create a pointcut to intercept all methods in a class with PostSharp?

I've tried using AttributeTargetTypes, but it just won't work. What am I missing?
The easiest way to apply an aspect to all methods of a class is to annotate this class with the aspect custom attribute. AttributeTargetTypes, when the custom attribute is applied on assembly-level, should work also, at least if the type is a part of the current assembly.