forked from jmix-framework/jmix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fragments jmix-framework#841 (set declarative parameters after autowi…
…ring)
- Loading branch information
Showing
8 changed files
with
185 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
jmix-flowui/flowui/src/test/java/component/fragment/component/TestParametersFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package component.fragment.component; | ||
|
||
import com.vaadin.flow.component.formlayout.FormLayout; | ||
import io.jmix.flowui.component.combobox.EntityComboBox; | ||
import io.jmix.flowui.component.textfield.TypedTextField; | ||
import io.jmix.flowui.fragment.Fragment; | ||
import io.jmix.flowui.fragment.FragmentDescriptor; | ||
import io.jmix.flowui.model.CollectionContainer; | ||
import io.jmix.flowui.view.ViewComponent; | ||
import test_support.entity.sales.Product; | ||
|
||
@FragmentDescriptor("test-parameters-fragment.xml") | ||
public class TestParametersFragment extends Fragment<FormLayout> { | ||
|
||
@ViewComponent | ||
private EntityComboBox<Product> entityField; | ||
@ViewComponent | ||
private TypedTextField<String> textField; | ||
|
||
public void setContainer(CollectionContainer<Product> container) { | ||
entityField.setItems(container); | ||
} | ||
|
||
public void setPlaceholder(String placeholder) { | ||
textField.setPlaceholder(placeholder); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
jmix-flowui/flowui/src/test/java/component/fragment/view/TestParametersFragmentHostView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2024 Haulmont. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package component.fragment.view; | ||
|
||
import com.vaadin.flow.router.Route; | ||
import component.fragment.component.TestAddressFragmentProvided; | ||
import component.fragment.component.TestParametersFragment; | ||
import io.jmix.flowui.Fragments; | ||
import io.jmix.flowui.model.CollectionContainer; | ||
import io.jmix.flowui.view.*; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import test_support.entity.sales.Product; | ||
|
||
@Route(value = "TestParametersFragmentHostView") | ||
@ViewController | ||
@ViewDescriptor("test-parameters-fragment-host-view.xml") | ||
@EditedEntityContainer("addressDc") | ||
public class TestParametersFragmentHostView extends StandardView { | ||
|
||
@ViewComponent | ||
private CollectionContainer<Product> productsDc; | ||
|
||
@Autowired | ||
private Fragments fragments; | ||
|
||
@Subscribe | ||
public void onInit(InitEvent event) { | ||
TestParametersFragment fragment = fragments.create(this, TestParametersFragment.class); | ||
fragment.setContainer(productsDc); | ||
fragment.setPlaceholder("Placeholder"); | ||
|
||
getContent().add(fragment); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...lowui/flowui/src/test/resources/component/fragment/component/test-parameters-fragment.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!-- | ||
~ Copyright 2024 Haulmont. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ https://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<fragment xmlns="https://jmix.io/schema/flowui/fragment"> | ||
<content> | ||
<formLayout> | ||
<entityComboBox id="entityField" metaClass="test_Product"/> | ||
<textField id="textField"/> | ||
</formLayout> | ||
</content> | ||
</fragment> |
40 changes: 40 additions & 0 deletions
40
.../flowui/src/test/resources/component/fragment/view/test-parameters-fragment-host-view.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- | ||
~ Copyright 2024 Haulmont. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ https://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<view xmlns="https://jmix.io/schema/flowui/view"> | ||
<data> | ||
<collection id="productsDc" | ||
class="test_support.entity.sales.Product"> | ||
<fetchPlan extends="_base"/> | ||
<loader id="productsDl" readOnly="true"> | ||
<query> | ||
<![CDATA[select e from test_Product e]]> | ||
</query> | ||
</loader> | ||
</collection> | ||
</data> | ||
<facets> | ||
<dataLoadCoordinator auto="true"/> | ||
</facets> | ||
<layout> | ||
<fragment class="component.fragment.component.TestParametersFragment"> | ||
<properties> | ||
<property name="container" value="productsDc" type="CONTAINER_REF"/> | ||
<property name="placeholder" value="Placeholder"/> | ||
</properties> | ||
</fragment> | ||
</layout> | ||
</view> |