TFS Custom WorkItemType Set field to current user - visual-studio-2010

I'm trying to add a custom workitemtype to TFS.
I would like to have a field called SignOff, with possible values of Yes/No. Next to that I would like to have a field called SignOffBy - when you change the SignOff field the SignOffBy field should be set to the current user.
<FIELD name="Signoff" refname="MyProj.Signoff" type="String">
<ALLOWEDVALUES expanditems="true">
<LISTITEM value="Yes" />
<LISTITEM value="No" />
</ALLOWEDVALUES>
<DEFAULT from="value" value="No" />
</FIELD>
<FIELD name="Signoff By" refname="MyProj.SignoffBy" type="String">
<WHENCHANGED field="MyProj.Signoff">
<DEFAULT from="currentuser" />
</WHENCHANGED>
<WHENNOTCHANGED field="MyProj.SsoSignoff">
<READONLY />
<EMPTY />
</WHENNOTCHANGED>
</FIELD>
The problem seems to be that the SignOffBy field wants to be populated at all times. If I don't use the empty tag it just gets populated right away. I want it to be blank, but only get populated when the field gets changed. At the moment it's not changing at all - it's just blank and stays blank.

Instead of onchanged rules, have a WHEN rule for signoff being false, and set the field to EMPTY/READONLY as you currently do.
Have a second WHEN rule for the true case, and use a COPY rule to copy the currentuser value into the field instead of doing it via a DEFAULT rule.

Related

Solr not sorting copyField correctly

I'm trying to get Solr to sort by Title, but I'm having no luck.
In my Schema I have the "title" field as text_general for searching, and then a "title_sort" field as a string for sorting. I've created a copyField that should be taking the "title" text_general field and putting it into the "title_sort" field as a string.
<fields>
<field name="title" type="text_general" indexed="true" stored="true"/>
<field name="title_sort" type="string" indexed="true" stored="false" />
</fields>
<copyField source="title" dest="title_sort" />
When I run the sort query "title_sort desc" this is what I get back
title: Don’t Mind If I Do
title: Men Don't Run Marathons
title: Danny
Can a copyField not convert a text_general field into a string?
Solved with the help of #MatsLindh.
I'd been reloading the schema in the CoreAdmin panel, thinking that would make the changes. I had to reindex after adding the copyField instruction, as Solr will not go through all the documents and update secondary fields.

Override default validator of input in composite component

I'm developing a composite component with a default validator that may be used alongside a more restrictive custom validator. However, it didn't work as intented.
I boiled down the problem as below:
<h:inputText id="textId" value="#{bean.text}">
<f:validateLength for="textId" maximum="10" />
<f:validateLength for="textId" maximum="5" />
</h:inputText>
The validation for maximum=5 is not executed or the result is omitted, as only the maximum=10 rule results in proper feedback:
Text field: 1234567890123
searchForm:textId: Validation Error: Length is greater than allowable maximum of '10'
Text field: 1234567
passes
What is the reason behind this behavior? How can I achieve my requirement anyway?
from your comment, I assume, you have a component like this:
<cc:interface >
<cc:editableValueHolder name="text" targets="myText" />
</cc:interface>
<cc:implementation>
<h:inputText id="myText">
<f:validateLength maximum="10" />
</h:inputText>
</cc:implementation>
And you want to use it - assuming its called myInput - like this:
<ns:myInput>
<f:validateLength maximum="5" for="text" />
</ns:myInput>
hence, if no validateLength is given, your 10 should apply, else the other value, if it's more restrictive.
I think it is by design, that you can only use ONE validator for a certain validation type. So, to overcome this issue you have 3 options:
First, you could use a regex validator inside the component, like:
<h:inputText id="myText">
<f:validateRegex pattern=".{,10}" />
</h:inputText>
This would allow the component user to apply his own f:validateLength. But then ofc. he would no longer be able to apply his own f:validateRegex.
Another Option would be, to make the component user able to disable the build-in validation with a component attribute. But this however would completly bypass your contraint of length 10 if the user decides to disable it.
The best option (imho) would be to apply the maxLength as an own attribute, and validate that option against your contraint of max. 10 digits:
<cc:interface >
<cc:attribute name="maxLength" required="false" default="10"/>
</cc:interface>
<cc:implementation>
<h:inputText id="myText">
<f:validateLength maximum="#{(cc.attrs.maxLength > 10)? 10 : cc.attrs.maxLength}" />
</h:inputText>
</cc:implementation>
Usage would now be:
<ns:myInput maxLength="15">
<!-- This will apply your contraint of 10 -->
</ns:myInput>
<ns:myInput maxLength="3">
<!-- This will apply the component users constraint of 3 -->
</ns:myInput>
This also has the advantage, that the component user does not need to know about the actual name of the encapsuled editableValueHolder in order to apply a f:validateLength.
Also think about, if it really makes sence to limit the maxLength inside your component. Components should be able to work for any use-case on the designed datatype, unless they control the appearence of the component, for instance column count, items per page and the like.

How to insert url of a selected article from popup in joomla?

I have small plugin(which work for joomla article in admin) of joomla which has a field in xml file like :
<field name="url" type="modal_article" default="" label="Internal Link"
description="" />
Right now it contains only articleId when I save it.
How can I insert url of selected article like index.php?option=com_content&view=article&id=517&catid=28&Itemid=267 ?
if that is not possible how can I use Article select button of joomla admin editor in my custom plugin.
If you want to insert a url, change the type to url
<field name="url" type="url" default="" label="Internal Link"
description="" />
else if you want to have a proper article select, you're using the right type but your fieldset is not importing the modal_article, hence it's rendered as text (where you end up inserting the id). Just import modal_article from
administrator/components/com_content/models/fields/modal/article.php
like this:
<fieldset name="request"
addfieldpath="/administrator/components/com_content/models/fields">
<field name="url" type="modal_article" default="" label="Internal Link"
description="" />
this will make your current code show the modal select (you'll still need to select the right Itemid from the menu to build a proper url).
Finally, another field type you might want to consider is menuitem:
<field name="url" type="modal_article" default="" label="Internal Link"
description="" />
see the full docs on
http://docs.joomla.org/Standard_form_field_types

Separation of forms & also drop down menu alteration when object selected

In the image provided of my registration page, I wish to put a vertical separator inbetween the form on the left to have another form on the right to be completed for the registration but I have no idea how to do it.
http://puu.sh/1FJIA
Also the second part of my question pertains to the drop down menu, how would I put an extra option other than #_usergroups that when selected will alter the drop down menu to change into a text box? Below is the coding used for the xml.
<?xml version="1.0" encoding="UTF-8"?>
<form>
<fieldset name="default"
label="COM_USERS_REGISTRATION_DEFAULT_LABEL"
>
<field name="spacer" type="spacer" class="text"
label="COM_USERS_REGISTER_REQUIRED"
/>
<field name="name" type="text"
description="COM_USERS_REGISTER_NAME_DESC"
filter="string"
label="COM_USERS_REGISTER_NAME_LABEL"
message="COM_USERS_REGISTER_NAME_MESSAGE"
required="true"
size="30"
/>
<field name="username" type="text"
class="validate-username"
description="COM_USERS_DESIRED_USERNAME"
filter="username"
label="COM_USERS_REGISTER_USERNAME_LABEL"
message="COM_USERS_REGISTER_USERNAME_MESSAGE"
required="true"
size="30"
validate="username"
/>
<field name="password1" type="password"
autocomplete="off"
class="validate-password"
description="COM_USERS_DESIRED_PASSWORD"
field="password2"
filter="raw"
label="COM_USERS_REGISTER_PASSWORD1_LABEL"
message="COM_USERS_REGISTER_PASSWORD1_MESSAGE"
required="true"
size="30"
validate="equals"
/>
<field name="password2" type="password"
autocomplete="off"
class="validate-password"
description="COM_USERS_REGISTER_PASSWORD2_DESC"
filter="raw"
label="COM_USERS_REGISTER_PASSWORD2_LABEL"
message="COM_USERS_REGISTER_PASSWORD2_MESSAGE"
required="true"
size="30"
/>
<field name="email1" type="email"
description="COM_USERS_REGISTER_EMAIL1_DESC"
field="id"
filter="string"
label="COM_USERS_REGISTER_EMAIL1_LABEL"
message="COM_USERS_REGISTER_EMAIL1_MESSAGE"
required="true"
size="30"
unique="true"
validate="email"
/>
<field name="email2" type="email"
description="COM_USERS_REGISTER_EMAIL2_DESC"
field="email1"
filter="string"
label="COM_USERS_REGISTER_EMAIL2_LABEL"
message="COM_USERS_REGISTER_EMAIL2_MESSAGE"
required="true"
size="30"
validate="equals"
/>
<field name="title" type="sql"
default="-None Listed-"
label="Select your University"
description="Select the University you are currently attending, if
it's not on the list then create it below"
query="SELECT title FROM #__usergroups WHERE ID > '8 ' "
required="true"
/>
<field
name="captcha"
type="captcha"
label="COM_USERS_CAPTCHA_LABEL"
description="COM_USERS_CAPTCHA_DESC"
validate="captcha"
/>
</fieldset>
</form>
1. Vertical separator:
you can use a hack i.e. create some fields which will output markup.
The idea here is to insert an extra
<div style='width:50%'>
before the first field;
Then a
</div><div style='width:49%;border-left:1px dashed black'>
where you want the separator
and finally a at the end.
Create three new spacer fields.
You can either insert properly escaped html directly:
<field type="spacer" name="splitterinit" label="<div>" />
or put the html as language constants in the language file:
SPLITTER_MID="</div><div style='width:49%;border-left:1px dashed black'>"
and simply use the constant in the .xml:
<field type="spacer" name="splittermid" label="SPLITTER_MID" />
2. Extra text option:
Easy: Simply add a text field below to allow the user to type in.
Harder: Create a custom element, there you can write php and make it
as you want it
3. A word of advice
Chronoforms features a user registration override that lets you define all the fields you want, and for sure you'll find more similar extensions on the JED
Also, all community solutions feature custom profiles.

How to validate a select tag in struts 2 framework

I am a newbie into programming and i am currently employed as a junior programmer.
I am currently having some problems validating the select tags in one of my forms.
What i actually trying to do is to ensure that one item is selected before the user submits the form .
In the form i have;
<s:select list="assessmentTypes" headerKey="0" headerValue=" -- Select One --"
listKey="id" value="name" listValue="name" key="course.assessmenttype"
name="assessmenttype.id"/>
I have some knowledge of validation but not to sure how to do it for the select list.
I tried using a normal validation with strings but i don't think it is required in this case. for example;
<field name="course.assessmenttype">
<field-validator type="requiredstring">
<message>Please Select a value</message>
</field-validator>
</field>
all help would be appreciated, Thanks in advance.
One option is to use an int validator with a min value set. Since you want any value greater than 0.
<field name="course.assessmenttype">
<field-validator type="int">
<param name="min">1</param>
<message>Please Select a value to continue</message>
</field-validator>
</field>
Set headerKey="0" to headerKey=""
<field name="course.assessmenttype">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>Please Select a value to continue</message>
</field-validator>
</field>
<field name="course.assessmenttype">
<field-validator type="regex">
<param name="expression">assessmentTypes</param>
<message>Select a value to continue</message>
</field-validator>
</field>
instead of assessmentTypes, you can directly mention the dropdown list values. Make sure that your validator XML file is in the format <ActionClassname>-validation.xml,which should be in the same package as Action class

Resources